4 * @author willCodeForFood
6 import exceptions.DB4oManagerCreationException;
7 import gui.BookRuralHouseGUI;
11 import configuration.ConfigXML;
13 import java.awt.Color;
15 import java.awt.Rectangle;
16 import java.awt.Dimension;
17 import java.awt.BorderLayout;
18 import java.awt.FlowLayout;
19 import java.awt.GridLayout;
20 import java.awt.GridBagLayout;
21 import java.awt.GridBagConstraints;
22 import java.awt.event.WindowAdapter;
23 import java.awt.event.WindowEvent;
26 public class StartWindow extends JFrame {
28 private static final long serialVersionUID = 1L;
30 private JPanel jContentPane = null;
31 private JButton boton1 = null;
32 private JButton boton2 = null;
33 private JButton boton3 = null;
34 private static configuration.ConfigXML c;
36 //public static ApplicationFacadeInterface facadeInterface;
37 private JLabel lblNewLabel;
39 public static void main(String[] args) {
41 StartWindow a = new StartWindow();
46 c=ConfigXML.getInstance();
48 System.setProperty("java.security.policy", c.getJavaPolicyPath());
50 System.setSecurityManager(new RMISecurityManager());
52 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
54 c=configuration.ConfigXML.getInstance();
55 if (c.isBusinessLogicLocal()){
56 //facadeInterface=new FacadeImplementation();
60 final String businessLogicNode = c.getBusinessLogicNode();
61 // Remote service name
62 String serviceName = "/"+c.getServiceRMI();
63 // RMI server port number
64 int portNumber = Integer.parseInt(c.getPortRMI());
65 // RMI server host IP IP
66 /*facadeInterface = (ApplicationFacadeInterface) Naming.lookup("rmi://"
67 + businessLogicNode + ":" + portNumber + serviceName);*/
70 }/* catch (java.rmi.ConnectException e) {
71 a.lblNewLabel.setText("No business logic: Run BusinessLogicServer first!!");
72 a.lblNewLabel.setForeground(Color.RED);
73 System.out.println("Error in StartWindow: "+e.toString());
74 } catch (java.rmi.NotBoundException e) {
75 a.lblNewLabel.setText("No business logic: Maybe problems running BusinessLogicServer");
76 a.lblNewLabel.setForeground(Color.RED);
77 System.out.println("Error in StartWindow: "+e.toString());
78 } */catch (com.db4o.ext.DatabaseFileLockedException e) {
79 a.lblNewLabel.setText("Database locked: Do not run BusinessLogicServer or BusinessLogicServer!!");
80 a.lblNewLabel.setForeground(Color.RED);
81 System.out.println("Error in StartWindow: "+e.toString());
82 } catch (Exception e) {
83 a.lblNewLabel.setText("Error: "+e.toString());
84 a.lblNewLabel.setForeground(Color.RED);
85 System.out.println("Error in StartWindow: "+e.toString());
93 * This is the default constructor
96 public StartWindow() {
99 addWindowListener(new WindowAdapter() {
101 public void windowClosing(WindowEvent e) {
106 //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
112 * This method initializes this
116 private void initialize() {
117 // this.setSize(271, 295);
118 this.setSize(495, 290);
119 this.setContentPane(getJContentPane());
120 this.setTitle("Rural Houses");
124 * This method initializes jContentPane
126 * @return javax.swing.JPanel
128 private JPanel getJContentPane() {
129 if (jContentPane == null) {
130 GridLayout gridLayout = new GridLayout();
131 gridLayout.setRows(4);
132 gridLayout.setColumns(1);
133 jContentPane = new JPanel();
134 jContentPane.setLayout(gridLayout);
135 jContentPane.add(getLblNewLabel());
136 jContentPane.add(getBoton2(), null);
137 jContentPane.add(getBoton3(), null);
138 jContentPane.add(getBoton1(), null);
144 * This method initializes boton1
146 * @return javax.swing.JButton
148 private JButton getBoton1() {
149 if (boton1 == null) {
150 boton1 = new JButton();
151 boton1.setText("Book rural house");
152 boton1.addActionListener(new java.awt.event.ActionListener() {
153 public void actionPerformed(java.awt.event.ActionEvent e) {
154 // C?digo cedido por la univerdad
155 JFrame a = new BookRuralHouseGUI();
164 * This method initializes boton2
166 * @return javax.swing.JButton
168 private JButton getBoton2() {
169 if (boton2 == null) {
170 boton2 = new JButton();
171 boton2.setText("Login");
172 boton2.addActionListener(new java.awt.event.ActionListener() {
173 public void actionPerformed(java.awt.event.ActionEvent e) {
174 // C?digo cedido por la universidad
175 JFrame a = new LoginGUI();
184 * This method initializes boton3
186 * @return javax.swing.JButton
188 private JButton getBoton3() {
189 if (boton3 == null) {
190 boton3 = new JButton();
191 boton3.setText("Query availability");
192 boton3.addActionListener(new java.awt.event.ActionListener() {
193 public void actionPerformed(java.awt.event.ActionEvent e) {
194 // C?digo cedido por la universidad
195 //JFrame a = new QueryAvailabilityWindow();
196 JFrame a = new QueryAvailabilityGUI();
206 private JLabel getLblNewLabel() {
207 if (lblNewLabel == null) {
208 lblNewLabel = new JLabel("Select option:");
209 lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 13));
210 lblNewLabel.setForeground(Color.BLACK);
211 lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
216 } // @jve:decl-index=0:visual-constraint="0,0"