📄 mousedrag.java
字号:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class MouseDrag extends Applet implements MouseMotionListener
{
TextField text;
public void init()
{
text=new TextField();
setLayout(new BorderLayout());
setBackground(Color.green);
addMouseMotionListener(this);
add(text, "South");
}
public void mouseDragged(MouseEvent e)
{
text.setBackground(Color.red);
text.setText("鼠标的坐标:"+"("+e.getX()+", "+e.getY()+")");
}
public void mouseMoved(MouseEvent e)
{
text.setBackground(Color.blue);
text.setText("鼠标的坐标:"+"("+e.getX()+", "+e.getY()+")");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -