我刚写了个关于鼠标的东西,不过编译是出现问题,提示是:
Note:MultiListener.java uses or overrides a deprecated API.
Note:Recompile with -deprecation for details.
各位前辈,这个问题应该如何解决啊?谢谢!代码是:
import java.awt.*;
import java.awt.event.*;
public class MultiListener implements MouseListener,MouseMotionListener,WindowListener
{
private Frame f;
private TextField tf;
public static void main(String[] args)
{
MultiListener m1 = new MultiListener();
m1.go();
}
public void go()
{
Frame f = new Frame( "多个监听者 ");
f.add(new Label( "鼠标问题 "), "Nouth ");
tf = new TextField(30);
f.add(tf, "South ");
f.addMouseListener(this);
f.addMouseMotionListener(this);
f.addWindowListener(this);
f.resize(200,200);
f.show();
}
public void mouseDragged(MouseEvent e)
{
String s = "现在坐标: x = " + e.getX() + "\ty = " + e.getY();
tf.setText(s);
}
public void mouseMoved(MouseEvent e){}
public void mouseEntered(MouseEvent e)
{
String s = "鼠标进入 ";
tf.setText(s);
}
public void mouseExited(MouseEvent e)
{
String s = "鼠标消失 ";
tf.setText(s);
}
public void mouseClicked(MouseEvent e){}
public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
public void windowClosed(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowActivated(WindowEvent e){}
}
------解决方案--------------------
f.resize(200,200);
||
\/
f.setSize(200,200);
f.show();
||
\/
f.setVisible(true);
分别是第21,22行