📄 main1.java
字号:
//this pro will display the mouse x,y
import java.awt.*;
import java.awt.event.*;
public class Main1 implements MouseMotionListener,MouseListener,KeyListener
{
Label statusBar=new Label();
private Frame f;
String ch="";
public void go(){
f=new Frame("Example two");
f.add("West",statusBar);//there west or south is no use
f.addMouseListener(this);
f.addMouseMotionListener(this);
f.setSize(200,200);
f.show();
}
//mouse implement realization
public void mouseClicked(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
public void mouseDragged(MouseEvent e){
int x=e.getX();
int y=e.getY();
String status=ch+"("+x+","+y+")"+ch;//why
//maybe it will make it to a String
statusBar.setText(status);
}
public void mouseMoved(MouseEvent e){
int x=e.getX();
int y=e.getY();
String status="(x="+x+",y="+y+")"+ch;//why
//maybe it will make it to a String
statusBar.setText(status);
}
public void keyTyped(KeyEvent k){
}
public void keyPressed(KeyEvent k)
{
int charcode=k.getKeyCode();
if(charcode==KeyEvent.VK_SHIFT)ch="s";
if(charcode==KeyEvent.VK_CONTROL)ch="c";
}
public void keyReleased(KeyEvent k)
{
ch="ch";
}
public static void main(String[] args){
Main1 mwin=new Main1();
mwin.go();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -