testanonymous.java
来自「Java与面向对象程序设计实验教学讲义.复数类的实现,复数类的复杂运算,身份证号」· Java 代码 · 共 40 行
JAVA
40 行
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 + =
减小字号Ctrl + -
显示快捷键?