哪个方法是不推荐使用的啊,最好别用它因为那个方法可能会在后续的jdk版本中去掉。

解决方案 »

  1.   

    javac -deprecation ***.java
    就可以知道是哪个方法过时。
    jdk1.5
    用javac  -Xlint  **.java
      

  2.   

    呵呵,我想没把问题说清楚,用louisqiang(tenwin)提供的方法查了一下,结果就是鼠标进入画图区时,我把它变成十字光标,结果产生我发贴的这个问题,现在我还是想用这样的效果,类库中还有什么可以使用的?
      

  3.   

    没人知道不?
    setCursor(Cursor.CROSSHAIR_CURSOR);
    这句有错,应该用什么函数代替?
      

  4.   

    /**
     * @(#)StopMe.java 2004-3-24
     *
     * Copyright 2004 Opensource Develop Team. All rights reserved.
     */
    package com.opensource.internal;import javax.swing.*;
    import java.awt.*;
    public class CustomDesktop extends JFrame
    {
    JDesktopPane desktopPane = new JDesktopPane(); public CustomDesktop()
    {
    JInternalFrame jif = new JInternalFrame(
    "Drag and ResizeMe",
    true, true, true, true);
    jif.setBounds(10, 10, 250, 100);
    jif.setVisible(true);
    desktopPane.add(jif);
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(desktopPane, BorderLayout.CENTER);
    desktopPane.setDesktopManager(new OutlineManager());
    desktopPane.revalidate();
    setSize(500, 400);
    setVisible(true);
    } public static void main(String[] args)
    {
    new CustomDesktop();
    }
    }class OutlineManager extends DefaultDesktopManager
    {
    private Rectangle start, last;
    private boolean first = true; // dragging...
    public void beginDraggingFrame(JComponent frame)
    {
    initializeOutline(frame);
    } public void dragFrame(JComponent frame, int x, int y)
    {
    updateOutline(frame, x, y, start.width, start.height);
    } public void endDraggingFrame(JComponent frame)
    {
    endOutline(frame);
    } // resizing...
    public void beginResizingFrame(JComponent frame, int dir)
    {
    initializeOutline(frame);
    } public void resizeFrame(JComponent frame, int x, int y, int w, int h)
    {
    updateOutline(frame, x, y, w, h);
    } public void endResizingFrame(JComponent frame)
    {
    endOutline(frame);
    } // outline...
    private void initializeOutline(final JComponent frame)
    {
    frame.setVisible(false);
    start = frame.getBounds();
    last = new Rectangle(start);
    first = true; SwingUtilities.invokeLater(new Runnable()
    {
    public void run()
    {
                 updateOutline(frame, start.x,  start.y, start.width, start.height);
    }
    });
    } public void updateOutline(JComponent frame, int x, int y, int w, int h)
    {
    Container _container = frame.getParent();
    Graphics g = _container.getGraphics(); try
    {
    g.setXORMode(_container.getBackground());
    if (!first)
    {
    g.drawRect(last.x,  last.y,  last.width-1, last.height-1);
    }
    g.drawRect(x, y, w-1, h-1);
    first = false;
    }
    finally
    {
    g.dispose();
    last.setBounds(x, y, w, h);
    }
    } public void endOutline(JComponent frame)
    {
    frame.setVisible(true);
    setBoundsForFrame(
    frame, last.x, last.y, last.width, last.height);
    }
    }