-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyPartner.java
More file actions
149 lines (110 loc) · 5.14 KB
/
MyPartner.java
File metadata and controls
149 lines (110 loc) · 5.14 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import javax.swing.*;
import java.util.*;
import java.awt.event.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.awt.*;
public class MyPartner extends JFrame {
private static final long serialVersionUID = 1L;
private ArrayList<Pokemon> bag;
private JRadioButton j1,j2,j3,j4;
public MyPartner(){
super("Pokemon Game");
Container c = getContentPane();
Font myFont = null;
Font myFont2 = null;
try{
myFont = Font.createFont ( Font.TRUETYPE_FONT, new FileInputStream ( "font3/LmsPokedex-XEja.ttf" ) );
myFont2 = Font.createFont ( Font.TRUETYPE_FONT, new FileInputStream ( "font3/LmsPokedex-XEja.ttf" ) );
}catch ( FontFormatException error ){
}catch ( FileNotFoundException error ){
}catch ( IOException error ){
}
System.out.println(Bag.ball);
ArrayList<Pokemon> partner = AllPokemon.getPokemon(4);
bag = new ArrayList<Pokemon>();
JPanel head = new JPanel();
JLabel k1 = new JLabel("SELECT PARTNER ", JLabel.CENTER);
head.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
k1.setFont(myFont.deriveFont(Font.BOLD,20f));
head.setBackground(Color.BLACK);
k1.setForeground(Color.YELLOW);
head.add(k1);
JPanel radio = new JPanel();
radio.setBorder(BorderFactory.createEmptyBorder(50, 70, 10, 30));
radio.setLayout(new BoxLayout(radio, BoxLayout.Y_AXIS));
j1 = new JRadioButton(""+ partner.get(0),true);
j2 = new JRadioButton(""+ partner.get(1),false);
j3 = new JRadioButton(""+ partner.get(2),false);
j4 = new JRadioButton(""+ partner.get(3),false);
radio.add(j1);
radio.add(j2);
radio.add(j3);
radio.add(j4);
ButtonGroup group = new ButtonGroup();
group.add(j1);
group.add(j2);
group.add(j3);
group.add(j4);
JPanel button = new JPanel();
JButton btn = new JButton("SELECT");
button.setLayout(new BoxLayout(button, BoxLayout.X_AXIS));
btn.add(Box.createRigidArea(new Dimension(240, 20)));
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if(j1.isSelected()){
bag.removeAll(bag);
//System.out.println(Bag.ball);
Pokemon pokemonPartner = partner.get(0);
JOptionPane.showMessageDialog(null,"Your Pokemon : " + partner.get(0));
//bag.add(pokemonPartner);
MyPokeName frame = new MyPokeName(pokemonPartner,bag);
frame.playgui(pokemonPartner,bag);
setVisible(false);
} else if (j2.isSelected()) {
bag.removeAll(bag);
Pokemon pokemonPartner = partner.get(1);
//System.out.println(Bag.ball);
JOptionPane.showMessageDialog(null,"Your Pokemon : "+ partner.get(1));
//bag.add(pokemonPartner);
MyPokeName frame = new MyPokeName(pokemonPartner,bag);
frame.playgui(pokemonPartner,bag);
setVisible(false);
} else if (j3.isSelected()) {
bag.removeAll(bag);
Pokemon pokemonPartner = partner.get(2);
JOptionPane.showMessageDialog(null,"Your Pokemon : "+ partner.get(2));
//bag.add(pokemonPartner);
MyPokeName frame = new MyPokeName(pokemonPartner,bag);
frame.playgui(pokemonPartner,bag);
setVisible(false);
} else if(j4.isSelected()){
bag.removeAll(bag);
Pokemon pokemonPartner = partner.get(3);
JOptionPane.showMessageDialog(null,"Your Pokemon : "+ partner.get(3));
//bag.add(pokemonPartner);
MyPokeName frame = new MyPokeName(pokemonPartner,bag);
frame.playgui(pokemonPartner,bag);
setVisible(false);
}
}
});
JButton btn2 = new JButton("CANCEL");
btn2.add(Box.createRigidArea(new Dimension(240, 20)));
btn2.addActionListener(new ActionListener(){
//anonymous class
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(head, BorderLayout.NORTH);
setSize(555, 350);
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
}