0
我寫了一些代碼在java中創建一個簡單的鼠標事件。但我堅持這一點。有人可以請幫忙弄清楚這是什麼問題或者可能是我的代碼中缺少的東西。鼠標事件處理Java
package mouseeventshandling;
import java.awt.*;
import java.awt.event.*;
public class MouseEventsHandling extends Frame implements MouseListener, MouseMotionListener {
TextField tf;
public MouseEventsHandling(String title){
super(title);
tf=new TextField(60);
addMouseListener(this);
}
public void launchFrame(){
add(tf, BorderLayout.SOUTH);
setSize(300,300);
setVisible(true);
}
public void mouseClicked(MouseEvent me){
String msg = "Mouse Clicked";
tf.setText(msg);
}
public void mouseEntered(MouseEvent me){
String msg = "Mouse Entered Component";
tf.setText(msg);
}
public void mouseExited(MouseEvent me){
String msg = "Mouse Exited Component"'
tf.setText(msg);
}
public void mousePressed(MouseEvent me){
String msg = "Mouse pressed";
tf.setText(msg);
}
public void mouseReleased(MouseEvent me){
String msg = "Mouse released";
tf.setText(msg);
}
public void mouseDragged(MouseEvent me){
String msg = "Mouse dragged at " + me.getX() + "," + me.getY();
tf.setText(msg);
}
}
那麼問題是什麼? – richersoon