-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJFrameDemo
57 lines (47 loc) · 1.43 KB
/
JFrameDemo
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main;
import java.awt.AWTException;
import java.awt.BorderLayout;
import java.util.Scanner;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Main {
private static JFrame frame;
/**
* @param args
* @throws AWTException
*/
public static void main(String[] args) throws AWTException {
Scanner input = new Scanner(System.in);
System.out.println("hello");
while (input.nextBoolean()) {
int temp = (int)(Math.random() * 5);
JCheckBox[] boxes = makeFrame();
while(!boxes[temp].isSelected()){
}
frame.dispose();
}
}
public static JCheckBox[] makeFrame(){
frame = new JFrame("test");
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
JPanel checkBoxPanel = new JPanel();
JCheckBox exchangingCard1 = new JCheckBox("A");
checkBoxPanel.add(exchangingCard1);
JCheckBox exchangingCard2 = new JCheckBox("B");
checkBoxPanel.add(exchangingCard2);
JCheckBox exchangingCard3 = new JCheckBox("C");
checkBoxPanel.add(exchangingCard3);
JCheckBox exchangingCard4 = new JCheckBox("D");
checkBoxPanel.add(exchangingCard4);
JCheckBox exchangingCard5 = new JCheckBox("E");
checkBoxPanel.add(exchangingCard5);
mainPanel.add(checkBoxPanel);
frame.add(mainPanel);
frame.pack();
frame.setVisible(true);
JCheckBox[] toReturn = {exchangingCard1,exchangingCard2,exchangingCard3,exchangingCard4,exchangingCard5};
return toReturn;
}
}