1 22 package org.objectweb.petals.demo.travelagency.airline; 23 24 import javax.swing.SwingUtilities ; 25 import java.awt.BorderLayout ; 26 import javax.swing.JPanel ; 27 import javax.swing.JFrame ; 28 import java.awt.Dimension ; 29 import javax.swing.JMenuBar ; 30 import javax.swing.JMenu ; 31 import javax.swing.JMenuItem ; 32 import javax.swing.JToolBar ; 33 import java.awt.GridLayout ; 34 35 39 public class GUI extends JFrame { 40 41 private static final long serialVersionUID = 1L; 42 43 private JPanel jContentPane = null; 44 45 private JMenuBar jJMenuBar = null; 46 47 private JMenu jMenu = null; 48 49 private JMenuItem jMenuItem = null; 50 51 private JMenu jMenu1 = null; 52 53 private JMenuItem jMenuItem1 = null; 54 55 private JMenuItem jMenuItem2 = null; 56 57 private JMenuItem jMenuItem3 = null; 58 59 private JMenu jMenu2 = null; 60 61 private JMenuItem jMenuItem4 = null; 62 63 68 private JMenuBar getJJMenuBar() { 69 if (jJMenuBar == null) { 70 jJMenuBar = new JMenuBar (); 71 jJMenuBar.add(getJMenu()); 72 jJMenuBar.add(getJMenu1()); 73 jJMenuBar.add(getJMenu2()); 74 } 75 return jJMenuBar; 76 } 77 78 83 private JMenu getJMenu() { 84 if (jMenu == null) { 85 jMenu = new JMenu (); 86 jMenu.setText("File"); 87 jMenu.add(getJMenuItem()); 88 } 89 return jMenu; 90 } 91 92 97 private JMenuItem getJMenuItem() { 98 if (jMenuItem == null) { 99 jMenuItem = new JMenuItem (); 100 jMenuItem.setText("Exit"); 101 } 102 return jMenuItem; 103 } 104 105 110 private JMenu getJMenu1() { 111 if (jMenu1 == null) { 112 jMenu1 = new JMenu (); 113 jMenu1.setText("Server"); 114 jMenu1.add(getJMenuItem1()); 115 jMenu1.add(getJMenuItem2()); 116 jMenu1.add(getJMenuItem3()); 117 } 118 return jMenu1; 119 } 120 121 126 private JMenuItem getJMenuItem1() { 127 if (jMenuItem1 == null) { 128 jMenuItem1 = new JMenuItem (); 129 jMenuItem1.setText("Start"); 130 } 131 return jMenuItem1; 132 } 133 134 139 private JMenuItem getJMenuItem2() { 140 if (jMenuItem2 == null) { 141 jMenuItem2 = new JMenuItem (); 142 jMenuItem2.setText("Stop"); 143 } 144 return jMenuItem2; 145 } 146 147 152 private JMenuItem getJMenuItem3() { 153 if (jMenuItem3 == null) { 154 jMenuItem3 = new JMenuItem (); 155 jMenuItem3.setText("Info"); 156 } 157 return jMenuItem3; 158 } 159 160 165 private JMenu getJMenu2() { 166 if (jMenu2 == null) { 167 jMenu2 = new JMenu (); 168 jMenu2.setText("?"); 169 jMenu2.add(getJMenuItem4()); 170 } 171 return jMenu2; 172 } 173 174 179 private JMenuItem getJMenuItem4() { 180 if (jMenuItem4 == null) { 181 jMenuItem4 = new JMenuItem (); 182 jMenuItem4.setText("About"); 183 } 184 return jMenuItem4; 185 } 186 187 190 public static void main(String [] args) { 191 193 SwingUtilities.invokeLater(new Runnable () { 194 public void run() { 195 GUI thisClass = new GUI(); 196 thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 197 thisClass.setVisible(true); 198 } 199 }); 200 } 201 202 205 public GUI() { 206 super(); 207 initialize(); 208 } 209 210 215 private void initialize() { 216 this.setSize(650, 300); 217 this.setJMenuBar(getJJMenuBar()); 218 this.setContentPane(getJContentPane()); 219 this.setTitle("PEtALS demo - TravelAgency - Airline"); 220 } 221 222 227 private JPanel getJContentPane() { 228 if (jContentPane == null) { 229 GridLayout gridLayout = new GridLayout (); 230 gridLayout.setRows(1); 231 jContentPane = new JPanel (); 232 jContentPane.setLayout(gridLayout); 233 } 234 return jContentPane; 235 } 236 237 } | Popular Tags |