完成一个程序,实现在TextArea中输出最后一次鼠标单击的x,y坐标和连续单击次数

来源:百度知道 编辑:UC知道 时间:2024/06/17 23:29:49
必须要用java语言写。。。。

我很急。。

哪个高手帮帮忙。。

谢谢。

//-----------------操作后点击按钮可以显示鼠标最后单击或双击的位置,并统计次数
import java.awt.*;
import java.awt.event.*;

class WindowMouse extends Frame implements MouseListener, ActionListener {
TextArea textArea;
Button button;
public int danji = 0, shuangji = 0, x = 0, y = 0;

WindowMouse() {
setLayout(new BorderLayout());
addMouseListener(this);
button = new Button("统计");
button.addActionListener(this);
add(button, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
textArea = new TextArea(5, 28);
add(textArea, BorderLayout.CENTER);
textArea.addMouseListener(this);
setBounds(150, 150, 400, 400);
setVisible(true);
}

public void mousePressed(MouseEvent e) {
x = e.getX();
y = e.getY();
}

public void mouseReleased(MouseEve