package gui; /** * @author willCodeForFood */ import java.awt.Color; import java.awt.Font; import java.awt.KeyEventDispatcher; import java.awt.KeyboardFocusManager; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.rmi.RMISecurityManager; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.UIManager; import configuration.ConfigXML; @SuppressWarnings("deprecation") public class StartWindow extends JFrame { private static final long serialVersionUID = 1L; private JPanel jContentPane = null; private JButton boton2 = null; private JButton boton3 = null; private static configuration.ConfigXML c; private JLabel lblNewLabel; public static void main(String[] args) { StartWindow a = new StartWindow(); System.setProperty("java.security.policy", "java.policy"); a.setVisible(true); try { c = ConfigXML.getInstance(); System.setProperty("java.security.policy", c.getJavaPolicyPath()); System.setSecurityManager(new RMISecurityManager()); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); c = configuration.ConfigXML.getInstance(); } catch (com.db4o.ext.DatabaseFileLockedException e) { a.lblNewLabel .setText("Database locked: Do not run BusinessLogicServer or BusinessLogicServer!!"); a.lblNewLabel.setForeground(Color.RED); System.out.println("Error in StartWindow: " + e.toString()); } catch (Exception e) { a.lblNewLabel.setText("Error: " + e.toString()); a.lblNewLabel.setForeground(Color.RED); System.out.println("Error in StartWindow: " + e.toString()); } } /** * This is the default constructor */ public StartWindow() { super(); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit(1); } }); KeyboardFocusManager.getCurrentKeyboardFocusManager() .addKeyEventDispatcher(new KeyEventDispatcher() { @Override public boolean dispatchKeyEvent(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_ESCAPE: System.exit(1); } return false; } }); initialize(); // this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * This method initializes this * * @return void */ private void initialize() { // this.setSize(271, 295); this.setSize(495, 290); this.setContentPane(getJContentPane()); this.setTitle("Rural Houses"); } /** * This method initializes jContentPane * * @return javax.swing.JPanel */ private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(); jContentPane.setLayout(null); jContentPane.add(getLblNewLabel()); jContentPane.add(getBoton2()); jContentPane.add(getBoton3()); } return jContentPane; } /** * This method initializes boton2 * * @return javax.swing.JButton */ private JButton getBoton2() { if (boton2 == null) { boton2 = new JButton(); boton2.setBounds(0, 74, 479, 93); boton2.setText("Login"); boton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { // C?digo cedido por la universidad JFrame a = new LoginGUI(); a.setVisible(true); } }); } return boton2; } /** * This method initializes boton3 * * @return javax.swing.JButton */ private JButton getBoton3() { if (boton3 == null) { boton3 = new JButton(); boton3.setBounds(0, 165, 479, 87); boton3.setText("Query availability"); boton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { // C?digo cedido por la universidad // JFrame a = new QueryAvailabilityWindow(); JFrame a = new QueryAvailabilityGUI2(); a.setVisible(true); } }); } return boton3; } private JLabel getLblNewLabel() { if (lblNewLabel == null) { lblNewLabel = new JLabel("Select option:"); lblNewLabel.setBounds(0, 0, 479, 63); lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 13)); lblNewLabel.setForeground(Color.BLACK); lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER); } return lblNewLabel; } } // @jve:decl-index=0:visual-constraint="0,0"