📄 testaddlistener.java
字号:
import java.awt.*;
import java.awt.event.*;
public class TestAddListener implements ActionListener,WindowListener
{
Frame f;
Button b;
public void create()
{
f=new Frame("Testing");
b=new Button("press");
b.addActionListener(this);
f.addWindowListener(this);
f.add(b,"North");
f.setSize(200,200);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
System.out.println("这个按钮被按下!");
}
public void WindowActivated(WindowEvent e){};
public void WindowClosed(WindowEvent e){};
public void WindowClosing(WindowEvent e)
{
System.exit(1);
};
public void WindowDeactivated(WindowEvent e){};
public void WindowDeiconified(WindowEvent e){};
public void WindowIconified(WindowEvent e){};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -