資源簡介
用標簽(Label)實現對鼠標坐標位置的顯示
代碼片段和文件信息
import?java.awt.*;
import?java.awt.event.*;
import?javax.swing.*;
public?class?TestMouse?extends?Jframe?implements?MouseMotionListener{
static?Label?lab=?new?Label();
????????static?JPanel?p=new?JPanel();
public?TestMouse()
{
super(“鼠標事件演示“);
}
public?static?void?main(String[]?args)?{
TestMouse?tm?=?new?TestMouse();
tm.setSize(300400);
????????????????tm.setLocationRelativeTo(null);????//不能設置開始位置
????????????????tm.getContentPane().add(pBorderLayout.CENTER);
????????????????p.add(lab);
p.addMouseMotionListener(tm); //對面板進行監聽,監聽者是實現MouseMotionListener的對象
tm.setVisible(true);
tm.setDefaultCloseOperation(JFram
- 上一篇:jd-gui.exe
- 下一篇:圖片拼接成一張圖片
評論
共有 條評論