当前位置: 代码迷 >> Java相关 >> 菜鸟求助:程序为何无法中止?
  详细解决方案

菜鸟求助:程序为何无法中止?

热度:184   发布时间:2006-08-09 17:50:25.0
菜鸟求助:程序为何无法中止?
import java.awt.*;
import java.awt.event.*;
public class TwoListenInner
{
private Frame f;
private TextField tf;
public static void main(String args[])
{
TwoListenInner that=new TwoListenInner();
that.go();
}
public void go()
{
f=new Frame("Two listeners example");
f.add("North",new Label("Click and drag the mouse"));
tf=new TextField(30);
f.add("South",tf);
f.addMouseMotionListener(new MouseMotionHandler());
f.addMouseListener(new MouseEventHandler());
f.setSize(300,300);
f.setVisible(true);
}
public class MouseMotionHandler extends MouseMotionAdapter
{
public void mouseDragged(MouseEvent e)
{
String s="Mouse Dragging:X="+e.getX()+"Y="+e.getY();
tf.setText(s);
}
};
public class MouseEventHandler extends MouseAdapter
{
public void mouseEntered(MouseEvent e)
{
String s="The Mouse Entered!";
tf.setText(s);
}
public void mouseExited(MouseEvent e)
{
String s="The Mouse Left the Building!";
tf.setText(s);
}
};
};
搜索更多相关的解决方案: void  class  private  example  public  

----------------解决方案--------------------------------------------------------
  相关解决方案