?? guidemo1.java
字號:
//Example 1 of Chapter 5
import java.awt.*;
public class GUIDemo1
{
public static void main(String[] args)
{
Frame f = new Frame("候選人輸入");
Panel p1 = new Panel();
Panel p2 = new Panel();
Panel p3 = new Panel();
Label l1 = new Label("第一候選人");
Label l2 = new Label("第二候選人");
Label l3 = new Label("第三候選人");
TextField t1 = new TextField(20);
TextField t2 = new TextField(20);
TextField t3 = new TextField(20);
Button b1 = new Button("輸入");
Button b2 = new Button("輸入");
Button b3 = new Button("輸入");
f.setLayout(new GridLayout(3,1));
p1.setLayout(new FlowLayout());
p2.setLayout(new FlowLayout());
p3.setLayout(new FlowLayout());
p1.add(l1);
p1.add(t1);
p1.add(b1);
p1.setBackground(Color.cyan);
p2.add(l2);
p2.add(t2);
p2.add(b2);
p2.setBackground(Color.yellow);
p3.add(l3);
p3.add(t3);
p3.add(b3);
p3.setBackground(Color.pink);
f.add(p1);
f.add(p2);
f.add(p3);
f.setSize( 300 , 160 );
f.setVisible(true);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -