butteventapp.java
来自「GUI事件处理例子」· Java 代码 · 共 23 行
JAVA
23 行
import java.awt.*;
import java.awt.event.*;
public class ButtEventApp extends Frame implements ActionListener{
static ButtEventApp frm=new ButtEventApp();
public static void main(String args[])
{
frm.setTitle("ButtEventApp");
frm.setSize(300,160);
frm.setLayout(null);
Button btn;
btn=new Button("push");
btn.setBounds(120,80,60,30);
btn.addActionListener(frm);
frm.add(btn,BorderLayout.CENTER);
frm.setVisible(true);
}
public void actionPerformed (ActionEvent e)
{
frm.setBackground(Color.red);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?