-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest0.java
More file actions
42 lines (40 loc) · 1.01 KB
/
test0.java
File metadata and controls
42 lines (40 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.awt.*;
import javax.swing.*;
public class test0 {
public static void main(String arg[]){
MyFrame mf = new MyFrame();
mf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mf.setVisible(true);
}
}
class MyFrame extends JFrame{
public MyFrame(){
this.setLocation(300,200);
this.setSize(500, 400);
MyPanel mp = new MyPanel();
this.add(mp);
}
}
class MyPanel extends JPanel{
JButton Confirm = new JButton("确认");
JButton Angin = new JButton("再来一次");
JButton Exit = new JButton("退出");
JLabel l1 = new JLabel("猜测次数\n\n\n");
JLabel l2 = new JLabel("输入猜测的数:");
JTextField txt = new JTextField();
JLabel l3 = new JLabel("太小");
JPanel input = new JPanel();
JPanel button = new JPanel();
public MyPanel(){
button.setLayout(new FlowLayout());
button.add(l2);
button.add(txt);
button.add(l3);
button.add(Confirm);
button.add(Angin);
button.add(Exit);
this.setLayout(new BorderLayout());
this.add(input,BorderLayout.CENTER);
this.add(button,BorderLayout.SOUTH);
}
}