6 import java.awt.event.ActionEvent;
7 import java.awt.event.ActionListener;
8 import java.awt.event.MouseAdapter;
9 import java.awt.event.MouseEvent;
10 import java.awt.event.WindowAdapter;
11 import java.awt.event.WindowEvent;
12 import java.util.Locale;
15 * @author Software Engineering teachers
17 import javax.swing.ButtonGroup;
18 import javax.swing.ImageIcon;
19 import javax.swing.JButton;
20 import javax.swing.JFrame;
21 import javax.swing.JLabel;
22 import javax.swing.JPanel;
23 import javax.swing.JRadioButton;
24 import javax.swing.SwingConstants;
26 import businessLogic.BLFacade;
27 import domain.RegularUser;
29 public class MainGUI extends JFrame {
31 private static final long serialVersionUID = 1L;
33 private JPanel jContentPane = null;
34 private JButton jButtonQueryQueries = null;
36 private static BLFacade appFacadeInterface = LoginGUI.getBusinessLogic();
38 private RegularUser ru = null;
39 protected JLabel jLabelSelectOption;
40 private JRadioButton rdbtnNewRadioButton;
41 private JRadioButton rdbtnNewRadioButton_1;
42 private JRadioButton rdbtnNewRadioButton_2;
44 private final ButtonGroup buttonGroup = new ButtonGroup();
45 private JButton btnModificar = new JButton();
46 private JLabel lblSaldo;
47 private RegularUser userlog = null;
48 private JButton btnBet;
50 private JButton btnHistorial;
51 private JButton btnAnularApuesta;
53 private JButton btnCargarSaldo = new JButton("Load Balance");
55 private JLabel lblFotoPerfil = new JLabel("");
57 private JLabel lblFotoCargar = new JLabel("");
58 private JLabel lblFotoMakeBet = new JLabel("");
59 private JLabel lblFotoHistorial = new JLabel("");
60 private JLabel lblFotoAnular = new JLabel("");
63 * This is the default constructor
65 public MainGUI(RegularUser ru) {
70 addWindowListener(new WindowAdapter() {
72 public void windowClosing(WindowEvent e) {
74 // if (ConfigXML.getInstance().isBusinessLogicLocal()) facade.close();
75 } catch (Exception e1) {
76 // TODO Auto-generated catch block
78 "Error: " + e1.toString() + " , probably problems with Business Logic or Database");
85 // this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
89 * This method initializes this
93 private void initialize() {
94 // this.setSize(271, 295);
95 setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
97 this.setSize(820, 650);
98 this.setContentPane(getJContentPane());
99 // this.setTitle(ResourceBundle.getBundle("Etiquetas").getString("MainTitle")
100 // + " " + userlog.getUserName());
102 "MainTitle" + " " + userlog.getUserName());
106 * This method initializes jContentPane
108 * @return javax.swing.JPanel
110 private JPanel getJContentPane() {
111 if (jContentPane == null) {
112 jContentPane = new JPanel();
113 jContentPane.setBackground(Color.WHITE);
114 jContentPane.setLayout(null);
116 jContentPane.add(getLblNewLabel());
117 btnModificar.addMouseListener(new MouseAdapter() {
119 public void mouseEntered(MouseEvent e) {
120 lblFotoPerfil.setVisible(true);
124 public void mouseExited(MouseEvent e) {
125 lblFotoPerfil.setVisible(false);
130 btnModificar.setBounds(45, 99, 422, 85);
131 // jContentPane.add(getBoton3());
132 jContentPane.add(getBoton2());
133 jContentPane.add(getBtnBet());
134 jContentPane.add(getPanel());
136 btnHistorial = new JButton();
137 btnHistorial.addMouseListener(new MouseAdapter() {
139 public void mouseEntered(MouseEvent e) {
140 lblFotoHistorial.setVisible(true);
144 public void mouseExited(MouseEvent e) {
145 lblFotoHistorial.setVisible(false);
149 btnHistorial.addActionListener(new ActionListener() {
151 public void actionPerformed(ActionEvent arg0) {
153 Frame reg = new HistorialApuestasGUI(userlog);
154 reg.setAlwaysOnTop(true);
155 reg.setVisible(true);
160 // btnHistorial.setText(ResourceBundle.getBundle("Etiquetas").getString("MainGUI.btnHistorial.text"));
161 // //$NON-NLS-1$ //$NON-NLS-2$
162 btnHistorial.setText("Check History");
163 btnHistorial.setBounds(45, 269, 422, 83);
164 jContentPane.add(btnHistorial);
165 jContentPane.add(getBtnAnularApuesta());
166 btnCargarSaldo.addMouseListener(new MouseAdapter() {
168 public void mouseEntered(MouseEvent arg0) {
169 lblFotoCargar.setVisible(true);
173 public void mouseExited(MouseEvent e) {
174 lblFotoCargar.setVisible(false);
178 btnCargarSaldo.addActionListener(new ActionListener() {
180 public void actionPerformed(ActionEvent arg0) {
182 Frame vista = new RecargarSaldoGUI(userlog);
183 vista.setAlwaysOnTop(true);
184 vista.setVisible(true);
190 btnCargarSaldo.setBounds(45, 436, 422, 83);
191 jContentPane.add(btnCargarSaldo);
193 ImageIcon icon = new ImageIcon("imagenes/miniatura.png");
194 lblFotoCargar = new JLabel(icon);
195 lblFotoCargar.setVisible(false);
196 lblFotoCargar.setBounds(485, 245, 259, 155);
197 jContentPane.add(lblFotoCargar);
199 ImageIcon icon2 = new ImageIcon("imagenes/makebet.png");
200 lblFotoMakeBet = new JLabel(icon2);
201 lblFotoMakeBet.setVisible(false);
202 lblFotoMakeBet.setBounds(485, 245, 259, 155);
203 jContentPane.add(lblFotoMakeBet);
205 ImageIcon icon3 = new ImageIcon("imagenes/anularbet.png");
206 lblFotoAnular = new JLabel(icon3);
207 lblFotoAnular.setVisible(false);
208 lblFotoAnular.setBounds(485, 245, 259, 155);
209 jContentPane.add(lblFotoAnular);
211 ImageIcon icon4 = new ImageIcon("imagenes/historial.png");
212 lblFotoHistorial = new JLabel(icon4);
213 lblFotoHistorial.setVisible(false);
214 lblFotoHistorial.setBounds(485, 245, 259, 155);
215 jContentPane.add(lblFotoHistorial);
217 ImageIcon icon5 = new ImageIcon("imagenes/perfil.png");
218 lblFotoPerfil = new JLabel(icon5);
219 lblFotoPerfil.setVisible(false);
220 lblFotoPerfil.setBounds(485, 245, 259, 155);
221 jContentPane.add(lblFotoPerfil);
223 JPanel panel_1 = new JPanel();
224 panel_1.setBackground(new Color(0, 0, 128));
225 panel_1.setBounds(554, 34, 145, 34);
226 jContentPane.add(panel_1);
227 panel_1.setLayout(null);
228 panel_1.add(getlblSaldo());
234 * This method initializes boton1
236 * @return javax.swing.JButton
238 private JButton getBoton2() {
240 // btnModificar.setText(ResourceBundle.getBundle("Etiquetas").getString("Show/EditProfile"));
241 btnModificar.setText("Show/EditProfile");
242 btnModificar.addActionListener(new ActionListener() {
244 public void actionPerformed(ActionEvent e) {
246 Frame reg = new ModificarDatosGUI(userlog);
247 reg.setAlwaysOnTop(true);
248 reg.setVisible(true);
257 * This method initializes boton2
259 * @return javax.swing.JButton
261 // private JButton getBoton3() {
262 // if (jButtonQueryQueries == null) {
263 // jButtonQueryQueries = new JButton();
264 // jButtonQueryQueries.setText(ResourceBundle.getBundle("Etiquetas").getString("QueryQueries"));
265 // jButtonQueryQueries.addActionListener(new java.awt.event.ActionListener() {
267 // public void actionPerformed(java.awt.event.ActionEvent e) {
268 // JFrame a = new FindQuestionsGUI();
269 // a.setAlwaysOnTop(true);
270 // a.setVisible(true);
271 // a.setVisible(true);
275 // return jButtonQueryQueries;
278 private JLabel getLblNewLabel() {
279 if (jLabelSelectOption == null) {
280 // jLabelSelectOption = new JLabel(ResourceBundle.getBundle("Etiquetas").getString("SelectOption"));
281 jLabelSelectOption = new JLabel("SelectOption");
282 jLabelSelectOption.setBounds(0, 12, 536, 97);
283 jLabelSelectOption.setFont(new Font("Tahoma", Font.BOLD, 13));
284 jLabelSelectOption.setForeground(Color.BLACK);
285 jLabelSelectOption.setHorizontalAlignment(SwingConstants.CENTER);
287 return jLabelSelectOption;
290 private JRadioButton getRdbtnNewRadioButton() {
291 if (rdbtnNewRadioButton == null) {
292 rdbtnNewRadioButton = new JRadioButton("English");
293 rdbtnNewRadioButton.setBackground(Color.WHITE);
294 rdbtnNewRadioButton.addActionListener(new ActionListener() {
296 public void actionPerformed(ActionEvent e) {
297 Locale.setDefault(new Locale("en"));
298 System.out.println("Locale: " + Locale.getDefault());
302 buttonGroup.add(rdbtnNewRadioButton);
304 return rdbtnNewRadioButton;
307 private JRadioButton getRdbtnNewRadioButton_1() {
308 if (rdbtnNewRadioButton_1 == null) {
309 rdbtnNewRadioButton_1 = new JRadioButton("Euskara");
310 rdbtnNewRadioButton_1.setBackground(Color.WHITE);
311 rdbtnNewRadioButton_1.addActionListener(new ActionListener() {
313 public void actionPerformed(ActionEvent arg0) {
314 Locale.setDefault(new Locale("eus"));
315 System.out.println("Locale: " + Locale.getDefault());
319 buttonGroup.add(rdbtnNewRadioButton_1);
321 return rdbtnNewRadioButton_1;
324 private JRadioButton getRdbtnNewRadioButton_2() {
325 if (rdbtnNewRadioButton_2 == null) {
326 rdbtnNewRadioButton_2 = new JRadioButton("Castellano");
327 rdbtnNewRadioButton_2.setBackground(Color.WHITE);
328 rdbtnNewRadioButton_2.addActionListener(new ActionListener() {
330 public void actionPerformed(ActionEvent e) {
331 Locale.setDefault(new Locale("es"));
332 System.out.println("Locale: " + Locale.getDefault());
336 buttonGroup.add(rdbtnNewRadioButton_2);
338 return rdbtnNewRadioButton_2;
341 private JPanel getPanel() {
343 panel = new JPanel();
344 panel.setBackground(Color.WHITE);
345 panel.setBounds(0, 543, 536, 40);
346 panel.add(getRdbtnNewRadioButton_1());
347 panel.add(getRdbtnNewRadioButton_2());
348 panel.add(getRdbtnNewRadioButton());
353 private void redibujar() {
354 // jLabelSelectOption.setText(ResourceBundle.getBundle("Etiquetas").getString("SelectOption"));
355 // btnBet.setText(ResourceBundle.getBundle("Etiquetas").getString("MakeBet"));
356 // btnModificar.setText(ResourceBundle.getBundle("Etiquetas").getString("Show/EditProfile"));
357 // btnHistorial.setText(ResourceBundle.getBundle("Etiquetas").getString("MainGUI.btnHistorial.text"));
359 // ResourceBundle.getBundle("Etiquetas").getString("MainGUI.lblSaldo") + " " + userlog.getBalance() + "€");
360 // this.setTitle(ResourceBundle.getBundle("Etiquetas").getString("MainTitle"));
361 // btnAnularApuesta.setText(ResourceBundle.getBundle("Etiquetas").getString("MainGUI.btnAnularApuesta.text"));
362 // btnCargarSaldo.setText(ResourceBundle.getBundle("Etiquetas").getString("MainGUI.cargarSaldo"));
364 jLabelSelectOption.setText("SelectOption");
365 btnBet.setText("Bet");
366 btnModificar.setText("Show/EditProfile");
367 btnHistorial.setText("CheckHistory");
368 lblSaldo.setText("Balance" + " " + userlog.getBalance() + "€");
369 this.setTitle("MainTitle");
370 btnAnularApuesta.setText("Cancel Bet");
371 btnCargarSaldo.setText("Load Balance");
375 public void close() {
376 this.setVisible(false);
379 private JButton getBtnBet() {
380 if (btnBet == null) {
381 btnBet = new JButton();
382 btnBet.addMouseListener(new MouseAdapter() {
384 public void mouseEntered(MouseEvent e) {
385 lblFotoMakeBet.setVisible(true);
389 public void mouseExited(MouseEvent e) {
390 lblFotoMakeBet.setVisible(false);
394 btnBet.setBounds(45, 184, 422, 85);
395 btnBet.addActionListener(new ActionListener() {
397 public void actionPerformed(ActionEvent arg0) {
398 Frame reg = new CreateBetGUI(userlog);
399 reg.setAlwaysOnTop(true);
400 reg.setVisible(true);
404 // btnBet.setText(ResourceBundle.getBundle("Etiquetas").getString("MakeBet"));
405 // //$NON-NLS-1$ //$NON-NLS-2$
406 btnBet.setText("MakeBet");
411 private JLabel getlblSaldo() {
412 if (lblSaldo == null) {
413 // lblSaldo = new JLabel(ResourceBundle.getBundle("Etiquetas").getString("MainGUI.lblSaldo") + " "
414 // + userlog.getBalance() + "€");
415 lblSaldo = new JLabel("Balance" + " " + userlog.getBalance() + "€");
416 lblSaldo.setBounds(8, 5, 205, 19);
417 lblSaldo.setFont(new Font("Tahoma", Font.BOLD, 14));
418 lblSaldo.setForeground(Color.WHITE);
423 private JButton getBtnAnularApuesta() {
424 if (btnAnularApuesta == null) {
425 btnAnularApuesta = new JButton();
426 btnAnularApuesta.addMouseListener(new MouseAdapter() {
428 public void mouseEntered(MouseEvent e) {
429 lblFotoAnular.setVisible(true);
433 public void mouseExited(MouseEvent e) {
434 lblFotoAnular.setVisible(false);
438 btnAnularApuesta.addActionListener(new ActionListener() {
440 public void actionPerformed(ActionEvent e) {
442 Frame reg = new AnularApuestaGUI(userlog);
443 reg.setAlwaysOnTop(true);
444 reg.setVisible(true);
449 // btnAnularApuesta.setText(ResourceBundle.getBundle("Etiquetas").getString("MainGUI.btnAnularApuesta.text")); //$NON-NLS-1$ //$NON-NLS-2$
450 btnAnularApuesta.setText("Cancel Bet");
451 btnAnularApuesta.setBounds(45, 352, 422, 83);
453 return btnAnularApuesta;
456 // @jve:decl-index=0:visual-constraint="0,0"