📄 testanonymous.java
字号:
import java.awt.*;
import java.awt.event.*;
public class TestAnonymous implements ActionListener{
Frame f;
TextArea tf;
Button bt;
int number=1;
public TestAnonymous(){
Label label=new Label("click and Drag the mouse");
f=new Frame("Test Inner class");
tf=new TextArea();
bt = new Button("退出");
tf.addMouseMotionListener(new MouseMotionAdapter(){
public void mouseDragged(MouseEvent e){
String s = number+++" "+"The mouse Dragged: x= "+
e.getX()+" y="+e.getY()+"\n";
tf.append(s);
}
});
bt.addActionListener(this);
f.add(label,BorderLayout.NORTH);
f.add(tf,BorderLayout.CENTER);
f.add(bt,BorderLayout.SOUTH);
f.setSize(300,200);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e){
System.exit(0);
}
public static void main(String args[]){
TestAnonymous two = new TestAnonymous( );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -