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
|
import javax.swing.event.*; import java.awt.event.*; import javax.swing.*; import java.awt.*; import java.io.*;
public class Help extends JPanel implements ActionListener{ GridBagConstraints gbc = new GridBagConstraints( ); JButton flamebutton = new JButton("HELP for F.L.A.M.E. Forms (Shown below)"); JButton flame1button = new JButton("HELP for F.L.A.M.E. Mobilization (Shown Below)"); JFrame f = new JFrame("Test");
public Help(){
ImageIcon fire = new ImageIcon("fire.gif"); ImageIcon amb = new ImageIcon("amb.gif"); ImageIcon hydrant = new ImageIcon("hydrant.gif"); ImageIcon vehicle = new ImageIcon("vehicle.gif"); ImageIcon duty = new ImageIcon("duty.gif"); ImageIcon training = new ImageIcon("cliff.gif"); ImageIcon asset = new ImageIcon("asset.gif"); ImageIcon staff = new ImageIcon("staff.gif"); ImageIcon inventory = new ImageIcon("inventory.gif"); ImageIcon flame = new ImageIcon("torch.gif"); ImageIcon explosion = new ImageIcon("explosion.gif");
gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.gridwidth = 1;
JPanel Main = new JPanel(); Main.setBorder(BorderFactory.createEtchedBorder());
JPanel Forms = new JPanel();
JLabel flame1label = new JLabel("", flame, SwingConstants.CENTER); addGB(Forms, flame1label, 0, 0); gbc.fill = GridBagConstraints.HORIZONTAL; addGB(Forms, flamebutton, 1, 0); flamebutton.addActionListener(this); gbc.fill = GridBagConstraints.BOTH; JLabel flame2label = new JLabel("", flame, SwingConstants.CENTER); addGB(Forms, flame2label, 2, 0);
JLabel firelabel = new JLabel("Fire Incident Report Form", fire, SwingConstants.LEFT); addGB(Forms, firelabel, 1, 1); JLabel amblabel = new JLabel("EMS Incident Report Form", amb, SwingConstants.LEFT); addGB(Forms, amblabel, 1, 2); JLabel inspectionlabel = new JLabel("Inspection Report Form", inventory, SwingConstants.LEFT); addGB(Forms, inspectionlabel, 1, 3); JLabel traininglabel = new JLabel("Personnel Training Report Form", training, SwingConstants.LEFT); addGB(Forms, traininglabel, 1, 4); JLabel hydrantlabel = new JLabel("Hydrant Report Form", hydrant, SwingConstants.LEFT); addGB(Forms, hydrantlabel, 1, 5); JLabel stafflabel = new JLabel("Staff Details Form", staff, SwingConstants.LEFT); addGB(Forms, stafflabel, 1, 6); JLabel vehiclelabel = new JLabel("Assets Management Form", vehicle, SwingConstants.LEFT); addGB(Forms, vehiclelabel, 1, 7); JLabel dutylabel = new JLabel("Operations Roster Form", duty, SwingConstants.LEFT); addGB(Forms, dutylabel, 1, 8);
gbc.fill = GridBagConstraints.HORIZONTAL; addGB(Forms, flame1button, 1, 10); flame1button.addActionListener(this); gbc.fill = GridBagConstraints.BOTH; JLabel firemoblabel = new JLabel("Fire Mobilization ", fire, SwingConstants.CENTER); addGB(Forms, firemoblabel, 1, 11); JLabel emsmoblabel = new JLabel("E.M.S. Mobilization", amb, SwingConstants.CENTER); addGB(Forms, emsmoblabel, 1, 12);
addGB(Main, Forms, 0, 0); addGB(this, Main, 0, 0);
}
public void actionPerformed(ActionEvent event) { try { String myEvent = event.getActionCommand(); if ( event.getSource() instanceof JButton) { if ("HELP for F.L.A.M.E. Forms (Shown below)".equals(myEvent)) { //Open file = new Open(); //file.Open(); } if ("HELP for F.L.A.M.E. Mobilization (Shown Below)".equals(myEvent)) { System.exit(0); } } } catch (Exception e) { System.out.println("An Error has occured at ListenForButtonPress :"+e.toString()); } }
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. Help"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setSize(1024,768); f.setLocation(0,0); f.setContentPane(new Help()); f.setVisible(true); } } |