?? guiframe.java
字號:
import java.awt.*;
import java.awt.event.*;
public class GUIFrame extends Frame implements ActionListener
{
Label label;
Button redButton;
Button greenButton;
public GUIFrame(String strTitle)
{
super(strTitle);
setLayout(new FlowLayout());
label=new Label("please choice one button.");
redButton=new Button("red");
greenButton=new Button("green");
add(label);
add(redButton);
add(greenButton);
redButton.addActionListener(this);
greenButton.addActionListener(this);
pack();
show();
}
public static void main(String args[])
{
GUIFrame frameDemo=new GUIFrame("This is the first GUI application program.");
frameDemo.addWindowListener(new WindowAdapter(){
public void windowsClosing(WindowEvent e)
{
System.exit(0);}
});
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==redButton){label.setText("you have press the red button");}
else{label.setText("you have press the green button");}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -