4 import java.awt.EventQueue;
6 import java.awt.GridLayout;
7 import java.awt.event.ActionEvent;
8 import java.awt.event.ActionListener;
9 import java.awt.event.WindowAdapter;
10 import java.awt.event.WindowEvent;
11 import java.util.Locale;
12 import java.util.ResourceBundle;
13 import java.util.Vector;
16 * @author Software Engineering teachers
18 import javax.swing.ButtonGroup;
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 businessLogic.BLFacadeImplementation;
30 public class MainGUI extends JFrame {
32 private static final long serialVersionUID = 1L;
34 private JPanel jContentPane = null;
35 private JButton jButtonCreateQuery = null;
36 private JButton jButtonQueryQueries = null;
38 private static BLFacade appFacadeInterface = LoginGUI.getBusinessLogic();
41 protected JLabel jLabelSelectOption;
42 private JRadioButton rdbtnNewRadioButton;
43 private JRadioButton rdbtnNewRadioButton_1;
44 private JRadioButton rdbtnNewRadioButton_2;
46 private final ButtonGroup buttonGroup = new ButtonGroup();
49 * This is the default constructor
54 addWindowListener(new WindowAdapter() {
56 public void windowClosing(WindowEvent e) {
58 // if (ConfigXML.getInstance().isBusinessLogicLocal()) facade.close();
59 } catch (Exception e1) {
60 // TODO Auto-generated catch block
62 "Error: " + e1.toString() + " , probably problems with Business Logic or Database");
69 // this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
73 * This method initializes this
77 private void initialize() {
78 // this.setSize(271, 295);
79 this.setSize(550, 363);
80 this.setContentPane(getJContentPane());
81 this.setTitle(ResourceBundle.getBundle("Etiquetas").getString("MainTitle"));
85 * This method initializes jContentPane
87 * @return javax.swing.JPanel
89 private JPanel getJContentPane() {
90 if (jContentPane == null) {
91 jContentPane = new JPanel();
92 jContentPane.setLayout(new GridLayout(4, 1, 0, 0));
93 jContentPane.add(getLblNewLabel());
94 jContentPane.add(getBoton3());
95 jContentPane.add(getBoton2());
96 jContentPane.add(getPanel());
102 * This method initializes boton1
104 * @return javax.swing.JButton
106 private JButton getBoton2() {
107 if (jButtonCreateQuery == null) {
108 jButtonCreateQuery = new JButton();
109 jButtonCreateQuery.setText(ResourceBundle.getBundle("Etiquetas").getString("CreateQuery"));
110 jButtonCreateQuery.addActionListener(new java.awt.event.ActionListener() {
111 public void actionPerformed(java.awt.event.ActionEvent e) {
112 JFrame a = new CreateQuestionGUI(new Vector<Event>());
113 a.setAlwaysOnTop(true);
118 return jButtonCreateQuery;
122 * This method initializes boton2
124 * @return javax.swing.JButton
126 private JButton getBoton3() {
127 if (jButtonQueryQueries == null) {
128 jButtonQueryQueries = new JButton();
129 jButtonQueryQueries.setText(ResourceBundle.getBundle("Etiquetas").getString("QueryQueries"));
130 jButtonQueryQueries.addActionListener(new java.awt.event.ActionListener() {
131 public void actionPerformed(java.awt.event.ActionEvent e) {
132 JFrame a = new FindQuestionsGUI();
133 a.setAlwaysOnTop(true);
139 return jButtonQueryQueries;
142 private JLabel getLblNewLabel() {
143 if (jLabelSelectOption == null) {
144 jLabelSelectOption = new JLabel(ResourceBundle.getBundle("Etiquetas").getString("SelectOption"));
145 jLabelSelectOption.setFont(new Font("Tahoma", Font.BOLD, 13));
146 jLabelSelectOption.setForeground(Color.BLACK);
147 jLabelSelectOption.setHorizontalAlignment(SwingConstants.CENTER);
149 return jLabelSelectOption;
152 private JRadioButton getRdbtnNewRadioButton() {
153 if (rdbtnNewRadioButton == null) {
154 rdbtnNewRadioButton = new JRadioButton("English");
155 rdbtnNewRadioButton.addActionListener(new ActionListener() {
156 public void actionPerformed(ActionEvent e) {
157 Locale.setDefault(new Locale("en"));
158 System.out.println("Locale: " + Locale.getDefault());
162 buttonGroup.add(rdbtnNewRadioButton);
164 return rdbtnNewRadioButton;
167 private JRadioButton getRdbtnNewRadioButton_1() {
168 if (rdbtnNewRadioButton_1 == null) {
169 rdbtnNewRadioButton_1 = new JRadioButton("Euskara");
170 rdbtnNewRadioButton_1.addActionListener(new ActionListener() {
171 public void actionPerformed(ActionEvent arg0) {
172 Locale.setDefault(new Locale("eus"));
173 System.out.println("Locale: " + Locale.getDefault());
177 buttonGroup.add(rdbtnNewRadioButton_1);
179 return rdbtnNewRadioButton_1;
182 private JRadioButton getRdbtnNewRadioButton_2() {
183 if (rdbtnNewRadioButton_2 == null) {
184 rdbtnNewRadioButton_2 = new JRadioButton("Castellano");
185 rdbtnNewRadioButton_2.addActionListener(new ActionListener() {
186 public void actionPerformed(ActionEvent e) {
187 Locale.setDefault(new Locale("es"));
188 System.out.println("Locale: " + Locale.getDefault());
192 buttonGroup.add(rdbtnNewRadioButton_2);
194 return rdbtnNewRadioButton_2;
197 private JPanel getPanel() {
199 panel = new JPanel();
200 panel.add(getRdbtnNewRadioButton_1());
201 panel.add(getRdbtnNewRadioButton_2());
202 panel.add(getRdbtnNewRadioButton());
208 private void redibujar() {
209 jLabelSelectOption.setText(ResourceBundle.getBundle("Etiquetas").getString("SelectOption"));
210 jButtonQueryQueries.setText(ResourceBundle.getBundle("Etiquetas").getString("QueryQueries"));
211 jButtonCreateQuery.setText(ResourceBundle.getBundle("Etiquetas").getString("CreateQuery"));
212 this.setTitle(ResourceBundle.getBundle("Etiquetas").getString("MainTitle"));
215 public void close() {
216 this.setVisible(false);
219 } // @jve:decl-index=0:visual-constraint="0,0"