1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
import javax.swing.event.*; import java.awt.event.*; import javax.swing.*; import java.awt.*;
public class FlameMenu extends JPanel implements ActionListener{ GridBagConstraints gbc = new GridBagConstraints( ); JButton formsbutton = new JButton("F.L.A.M.E. Forms"); JButton mobbutton = new JButton("F.L.A.M.E. Mobilization"); JFrame f = new JFrame("F.L.A.M.E. Forms"); JFrame fhelp = new JFrame("F.L.A.M.E. Help"); JFrame fmob = new JFrame("F.L.A.M.E. Mobilization"); public FlameMenu(){
gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.gridwidth = 1;
JMenu managermenu = new JMenu("System Manager"); managermenu.setMnemonic('N'); JMenu guidemenu = new JMenu("System Guide"); guidemenu.setMnemonic('G');
JMenuItem updateItem = new JMenuItem("Updating Information"); updateItem.setMnemonic('U'); updateItem.addActionListener(this); JMenuItem retrieveItem = new JMenuItem("Retrieving Information"); retrieveItem.setMnemonic('R'); retrieveItem.addActionListener(this); JMenuItem exitItem = new JMenuItem("Exit the System"); exitItem.setMnemonic('E'); exitItem.addActionListener(this); JMenuItem helpItem = new JMenuItem("System Help"); helpItem.setMnemonic('H'); helpItem.addActionListener(this);
managermenu.add(updateItem); managermenu.add(retrieveItem); managermenu.add(exitItem); guidemenu.add(helpItem);
JMenuBar bar = new JMenuBar(); bar.add(managermenu); bar.add(guidemenu); gbc.fill = GridBagConstraints.HORIZONTAL; addGB(this,bar,0,0);
JPanel Top = new JPanel(); Icon image = new ImageIcon("paramedic.gif"); JLabel select = new JLabel("Select a Task From Below",image,SwingConstants.CENTER); select.setHorizontalTextPosition(SwingConstants.CENTER); select.setVerticalTextPosition(SwingConstants.BOTTOM); addGB(Top,select, 0, 0); addGB(this,Top,0,1); JPanel Bottom = new JPanel(); JPanel Right = new JPanel(); JPanel Left = new JPanel(); gbc.fill = GridBagConstraints.NONE; addGB(Left,formsbutton, 0, 0); formsbutton.addActionListener(this); addGB(Right,mobbutton, 0, 0); mobbutton.addActionListener(this); addGB(Bottom,Left, 0, 0); addGB(Bottom,Right, 1, 0); gbc.fill = GridBagConstraints.BOTH; addGB(this, Bottom, 0, 2); }
public void actionPerformed(ActionEvent event) { try { String myEvent = event.getActionCommand(); if ( event.getSource() instanceof JButton) { if ("F.L.A.M.E. Forms".equals(myEvent)) { f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) {System.exit(0);} }); f.getContentPane().add(new Forms(),BorderLayout.CENTER); f.setSize(1024,730); f.setLocation(0,0); f.setVisible(true); } else if ("F.L.A.M.E. Mobilization".equals(myEvent)) { fmob.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) {System.exit(0);} }); fmob.getContentPane().add(new Mob(),BorderLayout.CENTER); fmob.setSize(300,400); fmob.setLocation(400,200); fmob.setVisible(true); } } else if ( event.getSource() instanceof JMenuItem) { if ("Updating Information".equals(myEvent)) { DbProject db = new DbProject(); db.setSize(1000, 700); db.setVisible(true); } else if ("Retrieving Information".equals(myEvent)) { DbProject db = new DbProject(); db.setSize(1000, 700); db.setVisible(true); } else if ("Exit the System".equals(myEvent)) { System.exit(0); } else if ("System Help".equals(myEvent)) { fhelp.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) {System.exit(0);} }); fhelp.getContentPane().add(new Help(),BorderLayout.CENTER); fhelp.setSize(500,650); fhelp.setLocation(300,50); fhelp.setVisible(true); } } } catch (Exception e) { System.out.println("An Error has occured at ListenForButtonPress :"+e.toString()); } }
void DisposeFrame(){ System.out.println(fhelp.getTitle()); fhelp.toBack(); }
void addGB(Container cont, Component comp, int x, int y) { if ((cont.getLayout( ) instanceof GridBagLayout) == false) cont.setLayout(new GridBagLayout( )); gbc.gridx = x; gbc.gridy = y; cont.add(comp, gbc); }
public static void main(String[] args) { JFrame f = new JFrame("F.L.A.M.E. Main Menu"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setSize(600,300); f.setLocation(300,200); f.setContentPane(new FlameMenu()); f.setVisible(true); } } |