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 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
|
import java.awt.*; import java.awt.event.*; import javax.swing.*;
public class Inspection extends JPanel implements ActionListener{
GridBagConstraints gbc = new GridBagConstraints(); String strQuery = new String(); JLabel buildingLabel = new JLabel ("Building :"); JLabel addressLabel = new JLabel ("Address :"); JLabel departmentLabel = new JLabel ("Department :"); JLabel contactLabel = new JLabel ("Contact :"); JLabel directorLabel = new JLabel ("Director :"); JLabel dateLabel = new JLabel ("Inspection Date :"); JLabel rmLabel = new JLabel ("RM Control No. :"); JLabel facmanLabel = new JLabel ("FACMAN WO No. :"); JLabel obsLabel = new JLabel ("Are all exit routes clear of obstructions?"); JLabel exitLabel = new JLabel ("Do all exit routes have lighted exit signs?"); JLabel bulbLabel = new JLabel ("Are all exit signs working with no burned out light bulbs?"); JLabel hallLabel = new JLabel ("Are all hallways and common areas illuminated?"); JLabel escapeLabel = new JLabel ("Are all fire escapes cleared of objects and in good condition?"); JLabel lockLabel = new JLabel ("Are all exit doors free of locking devices?"); JLabel planLabel = new JLabel ("Is there an exit plan posted on each floor"); JLabel smokeLabel = new JLabel ("When was the last time the smoke detectors were tested?"); JLabel placeLabel = new JLabel ("Are all the fire extinguishers in place and full?"); JLabel warnLabel = new JLabel ("Is the fire alarm system operating without warning sounds or lights?"); JLabel sprinkLabel = new JLabel ("Is there a working sprinkler system?"); JLabel inspectLabel = new JLabel ("When was the last time the kitchen suppression system was inspected?"); JLabel appLabel = new JLabel ("Are all electrical appliances in good working condition?"); JLabel cordLabel = new JLabel ("Are all electrical cords in good condition(no fraying or splices)?"); JLabel liquidLabel = new JLabel ("Are there any flammable liquids stored in the building?"); JLabel dryerLabel = new JLabel ("Is the laundry area kept clean and the dryer vents clear?"); JLabel trashLabel = new JLabel ("How often is the trash removed from the building?"); JLabel probLabel = new JLabel ("List problems found on self-inspection"); JLabel actionLabel = new JLabel ("List actions taken to rectify the problems encountered");
JComboBox dayBox = new JComboBox(); JComboBox monthBox = new JComboBox(); JComboBox yearBox = new JComboBox();
JTextField building = new JTextField(30); JTextField address1 = new JTextField(30); JTextField address2 = new JTextField(30); JTextField address3 = new JTextField(30); JTextField department = new JTextField(30); JTextField contact = new JTextField(30); JTextField director = new JTextField(30); JTextField date = new JTextField(30); JTextField rm = new JTextField(30); JTextField facman = new JTextField(30);
JCheckBox yes = new JCheckBox("Yes"); JCheckBox no = new JCheckBox("No"); JCheckBox yes1 = new JCheckBox("Yes"); JCheckBox no1 = new JCheckBox("No"); JCheckBox yes2 = new JCheckBox("Yes"); JCheckBox no2 = new JCheckBox("No"); JCheckBox yes3 = new JCheckBox("Yes"); JCheckBox no3 = new JCheckBox("No"); JCheckBox yes4 = new JCheckBox("Yes"); JCheckBox no4 = new JCheckBox("No"); JCheckBox yes5 = new JCheckBox("Yes"); JCheckBox no5 = new JCheckBox("No"); JCheckBox yes6 = new JCheckBox("Yes"); JCheckBox no6 = new JCheckBox("No"); JCheckBox yes8 = new JCheckBox("Yes"); JCheckBox no8 = new JCheckBox("No"); JCheckBox yes9 = new JCheckBox("Yes"); JCheckBox no9 = new JCheckBox("No"); JCheckBox yes10 = new JCheckBox("Yes"); JCheckBox no10 = new JCheckBox("No"); JCheckBox yes12 = new JCheckBox("Yes"); JCheckBox no12 = new JCheckBox("No"); JCheckBox yes13 = new JCheckBox("Yes"); JCheckBox no13 = new JCheckBox("No"); JCheckBox yes15 = new JCheckBox("Yes"); JCheckBox no15 = new JCheckBox("No"); JCheckBox yes17 = new JCheckBox("Yes"); JCheckBox no17 = new JCheckBox("No");
JTextArea smoke = new JTextArea(); JTextArea kit = new JTextArea(); JTextArea trash = new JTextArea(); JTextArea prob = new JTextArea(); JTextArea action = new JTextArea();
Icon quitbug = new ImageIcon("door.gif"); Icon submitbug = new ImageIcon("satelite.gif"); Icon clearfieldsbug = new ImageIcon("trash.gif"); Icon menubug = new ImageIcon("inventory.gif");
JButton quit = new JButton ("Quit",quitbug); JButton submit = new JButton ("Submit",submitbug); JButton clearfields = new JButton ("ClearFields",clearfieldsbug);
public Inspection(){ JPanel titleRow = new JPanel(); titleRow.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder())); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; gbc.weighty = 1.0; addGB(titleRow,buildingLabel, 0, 0); addGB(titleRow,building, 1, 0); addGB(titleRow,addressLabel, 0, 1); addGB(titleRow,address1, 1, 1); addGB(titleRow,address2, 1, 2); addGB(titleRow,address3, 1, 3); addGB(titleRow,departmentLabel, 0, 4); addGB(titleRow,department, 1, 4); addGB(titleRow,contactLabel, 2, 0); addGB(titleRow,contact, 3, 0); addGB(titleRow,directorLabel, 2, 1); addGB(titleRow,director, 3, 1); addGB(titleRow,dateLabel, 2, 2); addGB(titleRow,date, 3, 2); addGB(titleRow,rmLabel, 2, 3); addGB(titleRow,rm, 3, 3); addGB(titleRow,facmanLabel, 2, 4); addGB(titleRow,facman, 3, 4); addGB(this, titleRow, 0, 0);
JPanel questionRow = new JPanel(); questionRow.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder()));
addGB(questionRow,obsLabel, 0, 0); addGB(questionRow,yes, 0, 1); addGB(questionRow,no, 0, 2);
addGB(questionRow,exitLabel, 1, 0); addGB(questionRow,yes1, 1, 1); addGB(questionRow,no1, 1, 2);
addGB(questionRow,bulbLabel, 2, 0); addGB(questionRow,yes2, 2, 1); addGB(questionRow,no2, 2, 2);
addGB(questionRow,hallLabel, 0, 3); addGB(questionRow,yes3, 0, 4); addGB(questionRow,no3, 0, 5);
addGB(questionRow,escapeLabel, 1, 3); addGB(questionRow,yes4, 1, 4); addGB(questionRow,no4, 1, 5);
addGB(questionRow,lockLabel, 2, 3); addGB(questionRow,yes5, 2, 4); addGB(questionRow,no5, 2, 5);
addGB(questionRow,planLabel, 0, 6); addGB(questionRow,yes6, 0, 7); addGB(questionRow,no6, 0, 8);
addGB(questionRow,smokeLabel, 1, 6); JScrollPane locPane = new JScrollPane(smoke, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); addGB(questionRow,locPane, 1, 7);
addGB(questionRow,placeLabel, 2, 6); addGB(questionRow,yes8, 2, 7); addGB(questionRow,no8, 2, 8);
addGB(this, questionRow, 0, 1);
JPanel question1Row = new JPanel(); question1Row.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder()));
addGB(question1Row,warnLabel, 0, 0); addGB(question1Row,yes9, 0, 1); addGB(question1Row,no9, 0, 2);
addGB(question1Row,sprinkLabel, 1, 0); addGB(question1Row,yes10, 1, 1); addGB(question1Row,no10, 1, 2);
addGB(question1Row,inspectLabel, 0, 3); JScrollPane kitPane = new JScrollPane(kit, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); addGB(question1Row,kitPane, 0, 4);
addGB(question1Row,appLabel, 1, 3); addGB(question1Row,yes12, 1, 4); addGB(question1Row,no12, 1, 5);
addGB(question1Row,cordLabel, 0, 6); addGB(question1Row,yes13, 0, 7); addGB(question1Row,no13, 0, 8);
addGB(question1Row,liquidLabel, 1, 6); addGB(question1Row,yes15, 1, 7); addGB(question1Row,no15, 1, 8);
addGB(this, question1Row, 0, 2); JPanel question2Row = new JPanel(); question2Row.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder()));
addGB(question2Row,dryerLabel, 0, 0); addGB(question2Row,yes17, 0, 1); addGB(question2Row,no17, 0, 2);
addGB(question2Row,trashLabel, 1, 0); JScrollPane trashPane = new JScrollPane(trash, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); addGB(question2Row,trashPane, 1, 1);
addGB(question2Row,probLabel, 0, 3); JScrollPane probPane = new JScrollPane(prob, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); addGB(question2Row,probPane, 0, 4);
addGB(question2Row,actionLabel, 1, 3); JScrollPane actionPane = new JScrollPane(action, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); addGB(question2Row,actionPane, 1, 4);
addGB(this, question2Row, 0, 3);
JPanel fifthRow = new JPanel(); gbc.fill = GridBagConstraints.HORIZONTAL; addGB(fifthRow, quit, 0, 0); quit.addActionListener(this); addGB(fifthRow, new JLabel(""), 3, 0); addGB(fifthRow, submit, 4, 0); submit.addActionListener(this); addGB(fifthRow, new JLabel(""), 5, 0); addGB(fifthRow, clearfields, 6, 0); clearfields.addActionListener(this);
addGB(this, fifthRow, 0, 4); }
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 void actionPerformed(ActionEvent event) { try { String myEvent = event.getActionCommand(); if ( event.getSource() instanceof JButton) { if ( "Quit".equals(myEvent)) { System.exit(0); } if ( "Submit".equals(myEvent)) { Submit s = new Submit(); s.Open();
strQuery = "INSERT INTO inspection_1(building,address,dept,contact,director,idate,rm,facman)"; strQuery += "values ('" + building.getText() + "','" + address1.getText() + ","; strQuery += address2.getText() + "," + address3.getText() + "','" + department.getText(); strQuery += "','" + contact.getText() + "','" + director.getText() + "','" + date.getText(); strQuery += "','" + rm.getText() + "','" + facman.getText() + "')";
System.out.println(strQuery); s.Select(strQuery);
strQuery = "INSERT INTO inspection_2(indate,obs,exit,bulb,hall,escape,locked,plan,smoke,place)"; strQuery += "values ('" + date.getText() + "','";
if (yes.isSelected()) strQuery += yes.getText() + "','"; if (no.isSelected()) strQuery += no.getText() + "','"; if (yes1.isSelected()) strQuery += yes1.getText() + "','"; if (no1.isSelected()) strQuery += no1.getText() + "','"; if (yes2.isSelected()) strQuery += yes2.getText() + "','"; if (no2.isSelected()) strQuery += no2.getText() + "','"; if (yes3.isSelected()) strQuery += yes3.getText() + "','"; if (no3.isSelected()) strQuery += no3.getText() + "','"; if (yes4.isSelected()) strQuery += yes4.getText() + "','"; if (no4.isSelected()) strQuery += no4.getText() + "','"; if (yes5.isSelected()) strQuery += yes5.getText() + "','"; if (no5.isSelected()) strQuery += no5.getText() + "','"; if (yes6.isSelected()) strQuery += yes6.getText() + "','"; if (no6.isSelected()) strQuery += no6.getText() + "','";
strQuery += smoke.getText() + "','";
if (yes8.isSelected()) strQuery += yes8.getText(); if (no8.isSelected()) strQuery += no8.getText();
strQuery += "')";
System.out.println(strQuery); s.Select(strQuery);
s.Close(); } if ("ClearFields".equals(myEvent)) { smoke.setText(""); kit.setText(""); trash.setText(""); prob.setText(""); action.setText("");
building.setText(""); address1.setText(""); address2.setText(""); address3.setText(""); department.setText("");
contact.setText(""); director.setText(""); date.setText(""); rm.setText(""); facman.setText(""); } } } catch (Exception e) { System.out.println("An Error has occured at ListenForButtonPress :"+e.toString()); } }
public static void main(String[] args) { JFrame f = new JFrame("Inspection Report Form"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setSize(1024,768); f.setLocation(0,0); f.setContentPane(new Inspection()); f.setVisible(true); } } |