当前位置: 代码迷 >> Java相关 >> [求助]我能看懂英文,但还是不知道错在哪?
  详细解决方案

[求助]我能看懂英文,但还是不知道错在哪?

热度:168   发布时间:2006-12-23 20:48:20.0
[求助]我能看懂英文,但还是不知道错在哪?



代码。
import java.awt.*;
import java.awt.event.*;
public class MultListener implements MouseListener,MouseMotionListener,WindowListener

{
private Frame f;
private TextField tf;

public static void main(String [] args)
{
MultListener ml = new MultListener();
ml.go();
}
public void go()
{
Frame f = new Frame("多个监听者");
f.add( new Label("单击和拖动鼠标"),"North");
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 = "Mouse dragging : X = "+e.getX()+" Y = "+e.getY();
tf.setText(s);
}
public void mouseMoved(MouseEvent e){}
public void mouseEntered(MouseEvent e)
{
String s = "The mouse Exited";
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){}
}

搜索更多相关的解决方案: 英文  

----------------解决方案--------------------------------------------------------
MouseListener,MouseMotionListener,WindowListener


这三个接口的方法你没有实现完全

比如mouseExited就没有实现


----------------解决方案--------------------------------------------------------
我该怎么实现啊???
----------------解决方案--------------------------------------------------------

你可以不实现,但是你要声明
public void mouseExited(MouseEvent e){}

这个就和你别的方法一样


----------------解决方案--------------------------------------------------------
implements的意思你应该知道

所以既然你的类声明了要实现MouseListener,MouseMotionListener,WindowListener这三个接口
你就得实现这三个接口里面所有的方法

即使你没什么写的,你也可写一个空方法体在那进而

----------------解决方案--------------------------------------------------------

呵呵~~改好了~谢谢斑竹```
我还是不认真啊 马虎了~mouseExited漏了`
import java.awt.*;
import java.awt.event.*;
public class MultListener implements MouseListener,MouseMotionListener,WindowListener

{
private Frame f;
private TextField tf;

public static void main(String [] args)
{
MultListener ml = new MultListener();
ml.go();
}
public void go()
{
Frame f = new Frame("多个监听者");
f.add( new Label("单击和拖动鼠标"),"North");
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 = "Mouse dragging : X = "+e.getX()+" Y = "+e.getY();
tf.setText(s);
}
public void mouseMoved(MouseEvent e){}
public void mouseEntered(MouseEvent e)
{
String s = "The mouse Entered";
tf.setText(s);
}
public void mouseExited(MouseEvent e)
{
String s = "The mouse Exited";
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){}
}


----------------解决方案--------------------------------------------------------
好好学习

从基础开始吧

学程序不能急的

----------------解决方案--------------------------------------------------------
谢谢~我基础打了很久了,就是很少碰壁,现在多难为下自己,多碰碰,有好处。
----------------解决方案--------------------------------------------------------
呵呵,基础打了好久就不会看不懂编译出错的提示的

那些提示就是很简单的英文啊
----------------解决方案--------------------------------------------------------
  相关解决方案