6 import businessLogic.FacadeImplementation;
7 import businessLogic.ApplicationFacadeInterface;
10 import configuration.Config;
12 public class StartWindow extends JFrame {
14 public static boolean clientServer = false;
16 private static final long serialVersionUID = 1L;
18 private JPanel jContentPane = null;
19 private JButton bookHouseButton = null;
20 private JButton createOfferButton = null;
21 private JButton searchAvailabilityButton = null;
22 private JButton exitButton = null;
24 public static ApplicationFacadeInterface facadeInterface;
26 public StartWindow() {
29 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
32 public static ApplicationFacadeInterface getBusinessLogic(){
33 return facadeInterface;
36 private void initialize() {
37 // this.setSize(271, 295);
38 this.setSize(350, 400);
39 this.setContentPane(getJContentPane());
40 this.setTitle("Use Cases");
43 private JPanel getJContentPane() {
44 if (jContentPane == null) {
45 jContentPane = new JPanel();
46 // jContentPane.setLayout(null);
47 jContentPane.setLayout(new BoxLayout(jContentPane,
49 jContentPane.add(Box.createRigidArea(new Dimension(0,40)));
50 jContentPane.add(getBookHouseButton());
51 jContentPane.add(Box.createRigidArea(new Dimension(0,40)));
52 jContentPane.add(getSearchAvailabilityButton());
53 jContentPane.add(Box.createRigidArea(new Dimension(0,40)));
54 jContentPane.add(getCreateOfferButton());
55 jContentPane.add(Box.createRigidArea(new Dimension(0,40)));
56 jContentPane.add(getExitButton());
57 jContentPane.add(Box.createRigidArea(new Dimension(0,40)));
62 private JButton getBookHouseButton() {
63 if (bookHouseButton == null) {
64 bookHouseButton = new JButton();
65 bookHouseButton.setFont(new Font("Tahoma", Font.PLAIN, 24));
66 bookHouseButton.setText("Book rural house");
67 bookHouseButton.setAlignmentX(Component.CENTER_ALIGNMENT);
68 bookHouseButton.addActionListener(new java.awt.event.ActionListener() {
69 public void actionPerformed(java.awt.event.ActionEvent e) {
70 JFrame a = new BookRuralHouseGUI();
75 return bookHouseButton;
78 private JButton getCreateOfferButton() {
79 if (createOfferButton == null) {
80 createOfferButton = new JButton();
81 createOfferButton.setFont(new Font("Tahoma", Font.PLAIN, 24));
82 createOfferButton.setText("Introduce new offer");
83 createOfferButton.setAlignmentX(Component.CENTER_ALIGNMENT);
84 createOfferButton.addActionListener(new java.awt.event.ActionListener() {
85 public void actionPerformed(java.awt.event.ActionEvent e) {
86 JFrame a = new IntroduceOfferGUI();
91 return createOfferButton;
94 private JButton getSearchAvailabilityButton() {
95 if (searchAvailabilityButton == null) {
96 searchAvailabilityButton = new JButton();
97 searchAvailabilityButton.setFont(new Font("Tahoma", Font.PLAIN, 24));
98 searchAvailabilityButton.setText("Search availability");
99 searchAvailabilityButton.setAlignmentX(Component.CENTER_ALIGNMENT);
100 searchAvailabilityButton.addActionListener(new java.awt.event.ActionListener() {
101 public void actionPerformed(java.awt.event.ActionEvent e) {
102 JFrame a = new SearchOffersGUI();
107 return searchAvailabilityButton;
110 private JButton getExitButton() {
111 if (exitButton == null) {
112 exitButton = new JButton();
113 exitButton.setText("Exit");
114 exitButton.setFont(new Font("Tahoma", Font.PLAIN, 24));
115 exitButton.setAlignmentX(Component.CENTER_ALIGNMENT);
116 exitButton.addActionListener(new java.awt.event.ActionListener() {
117 public void actionPerformed(java.awt.event.ActionEvent e) {
118 //JFrame a = new QueryAvailabilityWindow();
119 ApplicationFacadeInterface facade=StartWindow.facadeInterface;
124 catch (RemoteException e1) {
125 // TODO Auto-generated catch block
126 e1.printStackTrace();
134 public static void main(String[] args) {
136 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
138 Config c=Config.getInstance();
140 facadeInterface=new FacadeImplementation();
142 final String serverRMI = c.getServerRMI();
143 // Remote service name
144 String serviceName = "/"+c.getServiceRMI();
145 //System.setSecurityManager(new RMISecurityManager());
146 // RMI server port number
147 int portNumber = Integer.parseInt(c.getPortRMI());
148 // RMI server host IP IP
149 facadeInterface = (ApplicationFacadeInterface) Naming.lookup("rmi://"
150 + serverRMI + ":" + portNumber + serviceName);
154 catch (Exception e) {
155 //System.out.println(e.toString());
159 JFrame a = new StartWindow();
163 } //@jve:decl-index=0:visual-constraint="0,0"