-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPair.java
More file actions
109 lines (86 loc) · 3.56 KB
/
Pair.java
File metadata and controls
109 lines (86 loc) · 3.56 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import javax.swing.*;
import java.util.*;
import java.awt.event.*;
import java.awt.*;
public class Pair extends JFrame {
private static final long serialVersionUID = 1L;
private ArrayList<Pokemon> male,female;
private ArrayList<Pokemon> bag;
public Pair(ArrayList<Pokemon> bags){
super("Pair Pokemon");
Container c = getContentPane();
bag = new ArrayList<Pokemon>();
male = new ArrayList<Pokemon>();
female = new ArrayList<Pokemon>();
try {
for(Pokemon b : bags){
bag.add(b);
}
} catch (NullPointerException e) {
JOptionPane.showMessageDialog(null,"No Pokemon");
}
JPanel head = new JPanel();
JLabel k1 = new JLabel("Hatch Pokemon", JLabel.CENTER);
head.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
k1.setFont(k1.getFont().deriveFont(Font.BOLD,35f));
head.setForeground(Color.green);
head.add(k1);
JPanel radio = new JPanel();
radio.setBorder(BorderFactory.createEmptyBorder(20, 20, 10, 30));
radio.setLayout(new BoxLayout(radio, BoxLayout.Y_AXIS));
ButtonGroup group = new ButtonGroup();
ButtonGroup group2 = new ButtonGroup();
System.out.println(bag);
for(int i = 0; i < bag.size(); ++i){
if(bag.get(i).getGen() == "Male"){
male.add(bag.get(i));
}
if(bag.get(i).getGen() == "Female"){
female.add(bag.get(i));
}
}
for(int i = 0; i < male.size(); ++i) {
if(male.get(i).getGen() == "Male")
{
System.out.println(male.get(i));
radio.add( new JRadioButton("" + i + " " + male.get(i),false));
group.add( new JRadioButton ("" + i + " " + male.get(i),false));
}
}
JPanel check = new JPanel();
check.setBorder(BorderFactory.createEmptyBorder(20, 30, 10, 20));
check.setLayout(new BoxLayout(check, BoxLayout.Y_AXIS));
for(int i = 0; i < female.size(); ++i) {
if(female.get(i).getGen() == "Female")
{
check.add( new JRadioButton ("" + i + " " + female.get(i),false));
group2.add( new JRadioButton ("" + i + " " + female.get(i),false));
}
}
JPanel button = new JPanel();
JButton btn = new JButton("SELECT");
button.setLayout(new BoxLayout(button, BoxLayout.X_AXIS));
btn.add(Box.createRigidArea(new Dimension(330, 20)));
btn.addActionListener ( new ActionListener ( ){
public void actionPerformed ( ActionEvent event ){
new Male(male,female,bag);
}
});
JButton btn2 = new JButton("CANCEL");
btn2.add(Box.createRigidArea(new Dimension(330, 20)));
btn2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});
button.add(btn);
button.add(btn2);
c.add(button, BorderLayout.SOUTH);
c.add(radio, BorderLayout.WEST);
c.add(check, BorderLayout.EAST);
c.add(head, BorderLayout.NORTH);
setSize(730, 350);
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
}