5 import java.awt.event.ActionEvent;
6 import java.awt.event.ActionListener;
7 import java.awt.event.MouseAdapter;
8 import java.awt.event.MouseEvent;
9 import java.awt.event.WindowAdapter;
10 import java.awt.event.WindowEvent;
11 import java.util.Locale;
12 import java.util.Vector;
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.AdminUser;
30 public class MainAdminGUI extends JFrame {
32 private static final long serialVersionUID = 1L;
34 private JPanel jContentPane = null;
35 private JButton jButtonCreateQuestion = null;
36 private JButton jButtonCreateEvent = null;
38 private static BLFacade appFacadeInterface = LoginGUI.getBusinessLogic();
40 protected JLabel jLabelSelectOption;
41 private JRadioButton rdbtnNewRadioButton;
42 private JRadioButton rdbtnNewRadioButton_1;
43 private JRadioButton rdbtnNewRadioButton_2;
45 private final ButtonGroup buttonGroup = new ButtonGroup();
46 private JButton jButtonCreateForecast;
47 private JButton buttonAdmin;
48 private AdminUser userlog = null;
49 private JButton buttonCloseEvent;
50 private JButton jButtonQueryQueries;
52 private JLabel lblFotoCrearEvento;
53 private JLabel lblFotoCrearQuestion;
54 private JLabel lblFotoCrearForecast;
55 private JLabel lblFotoSeeQuestions;
56 private JLabel lblFotoAdministration;
57 private JLabel lblFotoCloseEvent;
60 * This is the default constructor
62 public MainAdminGUI(AdminUser au) {
67 addWindowListener(new WindowAdapter() {
69 public void windowClosing(WindowEvent e) {
71 // if (ConfigXML.getInstance().isBusinessLogicLocal()) facade.close();
72 } catch (Exception e1) {
73 // TODO Auto-generated catch block
75 "Error: " + e1.toString() + " , probably problems with Business Logic or Database");
82 // this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
86 * This method initializes this
90 private void initialize() {
91 // this.setSize(271, 295);
92 setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
94 this.setSize(630, 421);
95 this.setContentPane(getJContentPane());
96 // this.setTitle(ResourceBundle.getBundle("Etiquetas").getString("MainTitle"));
97 this.setTitle("MainTitle");
102 * This method initializes jContentPane
104 * @return javax.swing.JPanel
106 private JPanel getJContentPane() {
107 if (jContentPane == null) {
108 jContentPane = new JPanel();
109 jContentPane.setBackground(Color.WHITE);
110 jContentPane.setLayout(null);
111 jContentPane.add(getLblNewLabel());
112 jContentPane.add(getBoton3());
113 jContentPane.add(getBoton2());
114 jContentPane.add(getJButtonCreateForecast());
115 jContentPane.add(getPanel());
116 jContentPane.add(getJButtonAdministration());
117 jContentPane.add(getbuttonCloseEvent());
119 jButtonQueryQueries = new JButton();
120 jButtonQueryQueries.addMouseListener(new MouseAdapter() {
122 public void mouseEntered(MouseEvent e) {
123 lblFotoSeeQuestions.setVisible(true);
127 public void mouseExited(MouseEvent e) {
128 lblFotoSeeQuestions.setVisible(false);
132 jButtonQueryQueries.addActionListener(new ActionListener() {
134 public void actionPerformed(ActionEvent e) {
135 JFrame a = new FindQuestionsGUI(userlog);
136 a.setAlwaysOnTop(true);
141 // jButtonQueryQueries.setText(
142 // ResourceBundle.getBundle("Etiquetas").getString("MainAdminGUI.jButtonQueryQuestions.text")); //$NON-NLS-1$ //$NON-NLS-2$
143 jButtonQueryQueries.setText("QueryQuestions"); //$NON-NLS-1$ //$NON-NLS-2$
144 jButtonQueryQueries.setBounds(34, 191, 267, 38);
145 jContentPane.add(jButtonQueryQueries);
147 ImageIcon icon = new ImageIcon("imagenes/fotoCrearEvento.png");
148 lblFotoCrearEvento = new JLabel(icon);
149 lblFotoCrearEvento.setBounds(320, 108, 265, 192);
150 lblFotoCrearEvento.setVisible(false);
151 jContentPane.add(lblFotoCrearEvento);
153 ImageIcon icon2 = new ImageIcon("imagenes/fotoCrearQuestion.png");
154 lblFotoCrearQuestion = new JLabel(icon2);
155 lblFotoCrearQuestion.setBounds(320, 108, 265, 192);
156 lblFotoCrearQuestion.setVisible(false);
157 jContentPane.add(lblFotoCrearQuestion);
159 ImageIcon icon3 = new ImageIcon("imagenes/fotoCrearForecast.png");
160 lblFotoCrearForecast = new JLabel(icon3);
161 lblFotoCrearForecast.setBounds(320, 108, 265, 192);
162 lblFotoCrearForecast.setVisible(false);
163 jContentPane.add(lblFotoCrearForecast);
165 ImageIcon icon4 = new ImageIcon("imagenes/fotoSeeQuestions.png");
166 lblFotoSeeQuestions = new JLabel(icon4);
167 lblFotoSeeQuestions.setBounds(320, 108, 265, 192);
168 lblFotoSeeQuestions.setVisible(false);
169 jContentPane.add(lblFotoSeeQuestions);
171 ImageIcon icon5 = new ImageIcon("imagenes/fotoAdministration.png");
172 lblFotoAdministration = new JLabel(icon5);
173 lblFotoAdministration.setBounds(320, 108, 265, 192);
174 lblFotoAdministration.setVisible(false);
175 jContentPane.add(lblFotoAdministration);
177 ImageIcon icon6 = new ImageIcon("imagenes/fotoCloseEvent.png");
178 lblFotoCloseEvent = new JLabel(icon6);
179 lblFotoCloseEvent.setBounds(320, 108, 265, 192);
180 lblFotoCloseEvent.setVisible(false);
181 jContentPane.add(lblFotoCloseEvent);
188 * This method initializes boton1
190 * @return javax.swing.JButton
192 private JButton getBoton2() {
193 if (jButtonCreateQuestion == null) {
194 jButtonCreateQuestion = new JButton();
195 jButtonCreateQuestion.addMouseListener(new MouseAdapter() {
197 public void mouseEntered(MouseEvent e) {
198 lblFotoCrearQuestion.setVisible(true);
202 public void mouseExited(MouseEvent e) {
203 lblFotoCrearQuestion.setVisible(false);
207 jButtonCreateQuestion.setBounds(34, 108, 267, 38);
208 // jButtonCreateQuestion.setText(ResourceBundle.getBundle("Etiquetas").getString("CreateQuestion"));
209 jButtonCreateQuestion.setText("CreateQuestion");
210 jButtonCreateQuestion.addActionListener(new java.awt.event.ActionListener() {
212 public void actionPerformed(java.awt.event.ActionEvent e) {
213 JFrame a = new CreateQuestionGUI(new Vector<Event>(), userlog);
214 a.setAlwaysOnTop(true);
220 return jButtonCreateQuestion;
224 * This method initializes boton2
226 * @return javax.swing.JButton
228 private JButton getBoton3() {
229 if (jButtonCreateEvent == null) {
230 jButtonCreateEvent = new JButton();
231 jButtonCreateEvent.addMouseListener(new MouseAdapter() {
233 public void mouseEntered(MouseEvent arg0) {
234 lblFotoCrearEvento.setVisible(true);
238 public void mouseExited(MouseEvent e) {
239 lblFotoCrearEvento.setVisible(false);
243 jButtonCreateEvent.setBounds(34, 67, 267, 38);
244 // jButtonCreateEvent.setText(ResourceBundle.getBundle("Etiquetas").getString("CreateEvent"));
245 jButtonCreateEvent.setText("CreateEvent");
246 jButtonCreateEvent.addActionListener(new java.awt.event.ActionListener() {
248 public void actionPerformed(java.awt.event.ActionEvent e) {
249 JFrame a = new CreateEventGUI(userlog);
250 a.setAlwaysOnTop(true);
257 return jButtonCreateEvent;
260 private JLabel getLblNewLabel() {
261 if (jLabelSelectOption == null) {
262 // jLabelSelectOption = new JLabel(ResourceBundle.getBundle("Etiquetas").getString("SelectOption"));
263 jLabelSelectOption = new JLabel("SelectOption");
264 jLabelSelectOption.setBounds(39, 8, 262, 76);
265 jLabelSelectOption.setFont(new Font("Tahoma", Font.BOLD, 13));
266 jLabelSelectOption.setForeground(Color.BLACK);
267 jLabelSelectOption.setHorizontalAlignment(SwingConstants.CENTER);
270 return jLabelSelectOption;
273 private JRadioButton getRdbtnNewRadioButton() {
274 if (rdbtnNewRadioButton == null) {
275 rdbtnNewRadioButton = new JRadioButton("English");
276 rdbtnNewRadioButton.setBackground(Color.WHITE);
277 rdbtnNewRadioButton.addActionListener(new ActionListener() {
279 public void actionPerformed(ActionEvent e) {
280 Locale.setDefault(new Locale("en"));
281 System.out.println("Locale: " + Locale.getDefault());
285 buttonGroup.add(rdbtnNewRadioButton);
287 return rdbtnNewRadioButton;
290 private JRadioButton getRdbtnNewRadioButton_1() {
291 if (rdbtnNewRadioButton_1 == null) {
292 rdbtnNewRadioButton_1 = new JRadioButton("Euskara");
293 rdbtnNewRadioButton_1.setBackground(Color.WHITE);
294 rdbtnNewRadioButton_1.addActionListener(new ActionListener() {
296 public void actionPerformed(ActionEvent arg0) {
297 Locale.setDefault(new Locale("eus"));
298 System.out.println("Locale: " + Locale.getDefault());
302 buttonGroup.add(rdbtnNewRadioButton_1);
304 return rdbtnNewRadioButton_1;
307 private JRadioButton getRdbtnNewRadioButton_2() {
308 if (rdbtnNewRadioButton_2 == null) {
309 rdbtnNewRadioButton_2 = new JRadioButton("Castellano");
310 rdbtnNewRadioButton_2.setBackground(Color.WHITE);
311 rdbtnNewRadioButton_2.addActionListener(new ActionListener() {
313 public void actionPerformed(ActionEvent e) {
314 Locale.setDefault(new Locale("es"));
315 System.out.println("Locale: " + Locale.getDefault());
319 buttonGroup.add(rdbtnNewRadioButton_2);
321 return rdbtnNewRadioButton_2;
324 private JPanel getPanel() {
326 panel = new JPanel();
327 panel.setBackground(Color.WHITE);
328 panel.setBounds(38, 318, 262, 38);
329 panel.add(getRdbtnNewRadioButton_1());
330 panel.add(getRdbtnNewRadioButton_2());
331 panel.add(getRdbtnNewRadioButton());
336 private void redibujar() {
337 // jLabelSelectOption.setText(ResourceBundle.getBundle("Etiquetas").getString("SelectOption"));
338 // jButtonCreateEvent.setText(ResourceBundle.getBundle("Etiquetas").getString("CreateEvent"));
339 // jButtonCreateQuestion.setText(ResourceBundle.getBundle("Etiquetas").getString("CreateQuestion"));
340 // jButtonCreateForecast
341 // .setText(ResourceBundle.getBundle("Etiquetas").getString("MainAdminGUI.jButtonCreateForecast.text"));
342 // jButtonQueryQueries
343 // .setText(ResourceBundle.getBundle("Etiquetas").getString("MainAdminGUI.jButtonQueryQuestions.text"));
344 // buttonAdmin.setText(ResourceBundle.getBundle("Etiquetas").getString("MainAdminGUI.buttonAdmin.text"));
345 // buttonCloseEvent.setText(ResourceBundle.getBundle("Etiquetas").getString("MainAdminGUI.buttonCloseEvent.text"));
347 // this.setTitle(ResourceBundle.getBundle("Etiquetas").getString("MainTitle"));
348 jLabelSelectOption.setText("SelectOption");
349 jButtonCreateEvent.setText("CreateEvent");
350 jButtonCreateQuestion.setText("CreateQuestion");
351 jButtonCreateForecast.setText("CreateForecast");
352 jButtonQueryQueries.setText("QueryQuestions");
353 buttonAdmin.setText("SeeStoredData");
354 buttonCloseEvent.setText("CloseEvent");
356 this.setTitle("MainTitle");
359 public void close() {
360 this.setVisible(false);
363 private JButton getJButtonCreateForecast() {
364 if (jButtonCreateForecast == null) {
365 jButtonCreateForecast = new JButton();
366 jButtonCreateForecast.addMouseListener(new MouseAdapter() {
368 public void mouseEntered(MouseEvent e) {
369 lblFotoCrearForecast.setVisible(true);
373 public void mouseExited(MouseEvent e) {
374 lblFotoCrearForecast.setVisible(false);
378 jButtonCreateForecast.addActionListener(new ActionListener() {
380 public void actionPerformed(ActionEvent e) {
381 JFrame a = new CreateForecastGUI(userlog);
382 a.setAlwaysOnTop(true);
387 jButtonCreateForecast.setBounds(34, 150, 267, 38);
388 // jButtonCreateForecast.setText(
389 // ResourceBundle.getBundle("Etiquetas").getString("MainAdminGUI.jButtonCreateForecast.text")); //$NON-NLS-1$ //$NON-NLS-2$
390 jButtonCreateForecast.setText("CreateForecast"); //$NON-NLS-1$ //$NON-NLS-2$
392 return jButtonCreateForecast;
395 private JButton getJButtonAdministration() {
396 if (buttonAdmin == null) {
397 buttonAdmin = new JButton();
398 buttonAdmin.addMouseListener(new MouseAdapter() {
400 public void mouseEntered(MouseEvent e) {
401 lblFotoAdministration.setVisible(true);
405 public void mouseExited(MouseEvent e) {
406 lblFotoAdministration.setVisible(false);
410 buttonAdmin.addActionListener(new ActionListener() {
412 public void actionPerformed(ActionEvent e) {
413 JFrame a = new AdministrationGUI(userlog);
414 a.setAlwaysOnTop(true);
419 buttonAdmin.setBounds(34, 232, 267, 38);
420 // buttonAdmin.setText(ResourceBundle.getBundle("Etiquetas").getString("MainAdminGUI.buttonAdmin.text")); //$NON-NLS-1$ //$NON-NLS-2$
421 buttonAdmin.setText("buttonAdmin"); //$NON-NLS-1$ //$NON-NLS-2$
426 private JButton getbuttonCloseEvent() {
427 if (buttonCloseEvent == null) {
428 buttonCloseEvent = new JButton();
429 buttonCloseEvent.addMouseListener(new MouseAdapter() {
431 public void mouseEntered(MouseEvent e) {
432 lblFotoCloseEvent.setVisible(true);
436 public void mouseExited(MouseEvent e) {
437 lblFotoCloseEvent.setVisible(false);
441 buttonCloseEvent.addActionListener(new ActionListener() {
443 public void actionPerformed(ActionEvent e) {
445 JFrame a = new CloseEventGUI(userlog);
446 a.setAlwaysOnTop(true);
451 buttonCloseEvent.setBounds(34, 273, 267, 38);
453 // .setText(ResourceBundle.getBundle("Etiquetas").getString("MainAdminGUI.buttonCloseEvent.text")); //$NON-NLS-1$ //$NON-NLS-2$
454 buttonCloseEvent.setText("CloseEvent"); //$NON-NLS-1$ //$NON-NLS-2$
455 jContentPane.add(buttonCloseEvent);
458 return buttonCloseEvent;
460 } // @jve:decl-index=0:visual-constraint="0,0"