Advertisement
Guest User

error

a guest
Jan 24th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.26 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5.  
  6. /*
  7. * NewJFrame.java
  8. *
  9. * Created on Oct 15, 2011, 12:29:48 AM
  10. */
  11.  
  12. /**
  13. * http://j4guiang.blogspot.com/
  14. * @author Jhovarie A. Guiang
  15. *
  16. * This code need mysql-connector.jar,JTatoo.jar,nimrodlf.jar and substance.jar
  17. */
  18.  
  19. import com.jtattoo.plaf.aero.AeroLookAndFeel;
  20. import com.jtattoo.plaf.aluminium.AluminiumLookAndFeel;
  21. import com.jtattoo.plaf.fast.FastLookAndFeel;
  22. import com.jtattoo.plaf.graphite.GraphiteLookAndFeel;
  23. import com.jtattoo.plaf.hifi.HiFiLookAndFeel;
  24. import com.nilo.plaf.nimrod.NimRODLookAndFeel;
  25. import com.sun.java.swing.plaf.motif.MotifLookAndFeel;
  26. import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel;
  27. import com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel;
  28. import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
  29. import java.sql.*;
  30. import javax.swing.*;
  31. import javax.swing.plaf.metal.MetalLookAndFeel;
  32. import org.jvnet.substance.skin.SubstanceEmeraldDuskLookAndFeel;
  33. import org.jvnet.substance.skin.SubstanceMagmaLookAndFeel;
  34. import org.jvnet.substance.skin.SubstanceModerateLookAndFeel;
  35. import org.jvnet.substance.skin.SubstanceNebulaBrickWallLookAndFeel;
  36. import org.jvnet.substance.skin.SubstanceNebulaLookAndFeel;
  37. import org.jvnet.substance.skin.SubstanceTwilightLookAndFeel;
  38. public class NewJFrame extends javax.swing.JFrame {
  39. Connection conn;
  40. String url;
  41. Statement stmt;
  42. ResultSet rs;
  43. /** Creates new form NewJFrame */
  44. public javax.swing.table.DefaultTableModel tableview;
  45. public NewJFrame() {
  46. initComponents();
  47. tableview= new javax.swing.table.DefaultTableModel();
  48. jTable1 = new javax.swing.JTable(tableview);
  49. tableview.addColumn("INDO");
  50. tableview.addColumn("First Name");
  51. tableview.addColumn("Last Name");
  52. tableview.addColumn("Gender");
  53. tableview.addColumn("Course");
  54. tableview.addColumn("Year Level");
  55. jScrollPane1.setViewportView(jTable1);
  56. try{
  57. url = "dbc:mysql://buiud.com:3306/buiud458_androidhive";
  58. Class.forName("com.mysql.jdbc.Driver");
  59. conn = DriverManager.getConnection(url,"XXX","XXX");
  60. stmt = conn.createStatement();
  61. jMenuItem8.setVisible(false);
  62. }catch(Exception e){
  63. int confirm = JOptionPane.showConfirmDialog
  64. (null, "Database not installed\ndo you want to install it now?", "",JOptionPane.YES_NO_OPTION);
  65. if(confirm == JOptionPane.YES_OPTION){
  66. InstallDatabase();
  67. }else if(confirm == JOptionPane.NO_OPTION){
  68. JOptionPane.showMessageDialog(null,"Database not installed");
  69. }
  70. }
  71. }
  72. @SuppressWarnings("unchecked")
  73. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  74. private void initComponents() {
  75.  
  76. jButton1 = new javax.swing.JButton();
  77. jButton2 = new javax.swing.JButton();
  78. jButton3 = new javax.swing.JButton();
  79. jButton4 = new javax.swing.JButton();
  80. jLabel6 = new javax.swing.JLabel();
  81. IDNO_txt = new javax.swing.JTextField();
  82. jScrollPane1 = new javax.swing.JScrollPane();
  83. jTable1 = new javax.swing.JTable();
  84. jPanel1 = new javax.swing.JPanel();
  85. jLabel1 = new javax.swing.JLabel();
  86. jLabel2 = new javax.swing.JLabel();
  87. jLabel3 = new javax.swing.JLabel();
  88. jLabel4 = new javax.swing.JLabel();
  89. jLabel5 = new javax.swing.JLabel();
  90. FirstName_txt = new javax.swing.JTextField();
  91. LastName_txt = new javax.swing.JTextField();
  92. Gender_cmb = new javax.swing.JComboBox();
  93. Course_cmb = new javax.swing.JComboBox();
  94. YearLevel_cmb = new javax.swing.JComboBox();
  95. jButton5 = new javax.swing.JButton();
  96. jComboBox1 = new javax.swing.JComboBox();
  97. jMenuBar1 = new javax.swing.JMenuBar();
  98. jMenu1 = new javax.swing.JMenu();
  99. jMenuItem1 = new javax.swing.JMenuItem();
  100. jMenuItem2 = new javax.swing.JMenuItem();
  101. jMenuItem3 = new javax.swing.JMenuItem();
  102. jMenuItem8 = new javax.swing.JMenuItem();
  103. jMenu2 = new javax.swing.JMenu();
  104. jMenuItem5 = new javax.swing.JMenuItem();
  105. jMenuItem6 = new javax.swing.JMenuItem();
  106. jMenuItem7 = new javax.swing.JMenuItem();
  107. jMenuItem9 = new javax.swing.JMenuItem();
  108. jMenuItem10 = new javax.swing.JMenuItem();
  109. jMenuItem11 = new javax.swing.JMenuItem();
  110. jMenuItem12 = new javax.swing.JMenuItem();
  111. jMenuItem13 = new javax.swing.JMenuItem();
  112. jMenuItem14 = new javax.swing.JMenuItem();
  113. jMenuItem4 = new javax.swing.JMenuItem();
  114. jMenuItem15 = new javax.swing.JMenuItem();
  115. jMenuItem16 = new javax.swing.JMenuItem();
  116. jMenuItem17 = new javax.swing.JMenuItem();
  117. jMenuItem18 = new javax.swing.JMenuItem();
  118. jMenuItem19 = new javax.swing.JMenuItem();
  119. jMenuItem20 = new javax.swing.JMenuItem();
  120.  
  121. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  122. setTitle("Registration System DEMO");
  123. setLocationByPlatform(true);
  124. setResizable(false);
  125.  
  126. jButton1.setText("Search");
  127. jButton1.addActionListener(new java.awt.event.ActionListener() {
  128. public void actionPerformed(java.awt.event.ActionEvent evt) {
  129. jButton1ActionPerformed(evt);
  130. }
  131. });
  132.  
  133. jButton2.setText("Save");
  134. jButton2.addActionListener(new java.awt.event.ActionListener() {
  135. public void actionPerformed(java.awt.event.ActionEvent evt) {
  136. jButton2ActionPerformed(evt);
  137. }
  138. });
  139.  
  140. jButton3.setText("Delete");
  141. jButton3.addActionListener(new java.awt.event.ActionListener() {
  142. public void actionPerformed(java.awt.event.ActionEvent evt) {
  143. jButton3ActionPerformed(evt);
  144. }
  145. });
  146.  
  147. jButton4.setText("Update");
  148. jButton4.addActionListener(new java.awt.event.ActionListener() {
  149. public void actionPerformed(java.awt.event.ActionEvent evt) {
  150. jButton4ActionPerformed(evt);
  151. }
  152. });
  153.  
  154. jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11));
  155. jLabel6.setText("Search");
  156.  
  157. IDNO_txt.setFont(new java.awt.Font("Tahoma", 1, 11));
  158.  
  159. jTable1.setModel(new javax.swing.table.DefaultTableModel(
  160. new Object [][] {
  161. {null, null, null, null, null},
  162. {null, null, null, null, null},
  163. {null, null, null, null, null},
  164. {null, null, null, null, null}
  165. },
  166. new String [] {
  167. "Title 1", "Title 2", "Title 3", "Title 4", "Title 5"
  168. }
  169. ));
  170. jScrollPane1.setViewportView(jTable1);
  171.  
  172. jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Demo Student Registration System"));
  173. jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
  174.  
  175. jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
  176. jLabel1.setText("First Name:");
  177. jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 40, 80, 20));
  178.  
  179. jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12));
  180. jLabel2.setText("Last Name:");
  181. jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 80, 70, 20));
  182.  
  183. jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11));
  184. jLabel3.setText("Gender:");
  185. jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 120, 70, 20));
  186.  
  187. jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11));
  188. jLabel4.setText("Course");
  189. jPanel1.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 160, 70, -1));
  190.  
  191. jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11));
  192. jLabel5.setText("Year Level");
  193. jPanel1.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 200, 80, -1));
  194.  
  195. FirstName_txt.setFont(new java.awt.Font("Tahoma", 1, 11));
  196. jPanel1.add(FirstName_txt, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 40, 340, -1));
  197.  
  198. LastName_txt.setFont(new java.awt.Font("Tahoma", 1, 11));
  199. jPanel1.add(LastName_txt, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 80, 340, -1));
  200.  
  201. Gender_cmb.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Choose one", "Male", "Female" }));
  202. jPanel1.add(Gender_cmb, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 120, 100, -1));
  203.  
  204. Course_cmb.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "BSIT", "BSCS" }));
  205. jPanel1.add(Course_cmb, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 160, 100, -1));
  206.  
  207. YearLevel_cmb.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1st year", "2nd year", "3rd year", "4rt year" }));
  208. jPanel1.add(YearLevel_cmb, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 200, 100, -1));
  209.  
  210. jButton5.setText("Reset");
  211. jButton5.addActionListener(new java.awt.event.ActionListener() {
  212. public void actionPerformed(java.awt.event.ActionEvent evt) {
  213. jButton5ActionPerformed(evt);
  214. }
  215. });
  216.  
  217. jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "IDNO", "Name" }));
  218.  
  219. jMenu1.setText("Menu");
  220.  
  221. jMenuItem1.setText("About");
  222. jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
  223. public void actionPerformed(java.awt.event.ActionEvent evt) {
  224. jMenuItem1ActionPerformed(evt);
  225. }
  226. });
  227. jMenu1.add(jMenuItem1);
  228.  
  229. jMenuItem2.setText("Help");
  230. jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
  231. public void actionPerformed(java.awt.event.ActionEvent evt) {
  232. jMenuItem2ActionPerformed(evt);
  233. }
  234. });
  235. jMenu1.add(jMenuItem2);
  236.  
  237. jMenuItem3.setText("Visit Site");
  238. jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
  239. public void actionPerformed(java.awt.event.ActionEvent evt) {
  240. jMenuItem3ActionPerformed(evt);
  241. }
  242. });
  243. jMenu1.add(jMenuItem3);
  244.  
  245. jMenuItem8.setText("Install Database");
  246. jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
  247. public void actionPerformed(java.awt.event.ActionEvent evt) {
  248. jMenuItem8ActionPerformed(evt);
  249. }
  250. });
  251. jMenu1.add(jMenuItem8);
  252.  
  253. jMenuBar1.add(jMenu1);
  254.  
  255. jMenu2.setText("Look And feel");
  256.  
  257. jMenuItem5.setText("MotifLookAndFeel");
  258. jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
  259. public void actionPerformed(java.awt.event.ActionEvent evt) {
  260. jMenuItem5ActionPerformed(evt);
  261. }
  262. });
  263. jMenu2.add(jMenuItem5);
  264.  
  265. jMenuItem6.setText("NimbusLookAndFeel");
  266. jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
  267. public void actionPerformed(java.awt.event.ActionEvent evt) {
  268. jMenuItem6ActionPerformed(evt);
  269. }
  270. });
  271. jMenu2.add(jMenuItem6);
  272.  
  273. jMenuItem7.setText("WindowsClassicLookAndFeel");
  274. jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
  275. public void actionPerformed(java.awt.event.ActionEvent evt) {
  276. jMenuItem7ActionPerformed(evt);
  277. }
  278. });
  279. jMenu2.add(jMenuItem7);
  280.  
  281. jMenuItem9.setText("WindowsLookAndFeel");
  282. jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
  283. public void actionPerformed(java.awt.event.ActionEvent evt) {
  284. jMenuItem9ActionPerformed(evt);
  285. }
  286. });
  287. jMenu2.add(jMenuItem9);
  288.  
  289. jMenuItem10.setText("HiFiLookAndFeel");
  290. jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
  291. public void actionPerformed(java.awt.event.ActionEvent evt) {
  292. jMenuItem10ActionPerformed(evt);
  293. }
  294. });
  295. jMenu2.add(jMenuItem10);
  296.  
  297. jMenuItem11.setText("GraphiteLookAndFeel");
  298. jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
  299. public void actionPerformed(java.awt.event.ActionEvent evt) {
  300. jMenuItem11ActionPerformed(evt);
  301. }
  302. });
  303. jMenu2.add(jMenuItem11);
  304.  
  305. jMenuItem12.setText("FastLookAndFeel");
  306. jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
  307. public void actionPerformed(java.awt.event.ActionEvent evt) {
  308. jMenuItem12ActionPerformed(evt);
  309. }
  310. });
  311. jMenu2.add(jMenuItem12);
  312.  
  313. jMenuItem13.setText("AluminiumLookAndFeel");
  314. jMenuItem13.addActionListener(new java.awt.event.ActionListener() {
  315. public void actionPerformed(java.awt.event.ActionEvent evt) {
  316. jMenuItem13ActionPerformed(evt);
  317. }
  318. });
  319. jMenu2.add(jMenuItem13);
  320.  
  321. jMenuItem14.setText("AeroLookAndFeel");
  322. jMenuItem14.addActionListener(new java.awt.event.ActionListener() {
  323. public void actionPerformed(java.awt.event.ActionEvent evt) {
  324. jMenuItem14ActionPerformed(evt);
  325. }
  326. });
  327. jMenu2.add(jMenuItem14);
  328.  
  329. jMenuItem4.setText("NimRODLookAndFeel");
  330. jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
  331. public void actionPerformed(java.awt.event.ActionEvent evt) {
  332. jMenuItem4ActionPerformed(evt);
  333. }
  334. });
  335. jMenu2.add(jMenuItem4);
  336.  
  337. jMenuItem15.setText("SubstanceMagmaLookAndFeel");
  338. jMenuItem15.addActionListener(new java.awt.event.ActionListener() {
  339. public void actionPerformed(java.awt.event.ActionEvent evt) {
  340. jMenuItem15ActionPerformed(evt);
  341. }
  342. });
  343. jMenu2.add(jMenuItem15);
  344.  
  345. jMenuItem16.setText("SubstanceEmeraldDuskLookAndFeel");
  346. jMenuItem16.addActionListener(new java.awt.event.ActionListener() {
  347. public void actionPerformed(java.awt.event.ActionEvent evt) {
  348. jMenuItem16ActionPerformed(evt);
  349. }
  350. });
  351. jMenu2.add(jMenuItem16);
  352.  
  353. jMenuItem17.setText("SubstanceNebulaBrickWallLookAndFeel");
  354. jMenuItem17.addActionListener(new java.awt.event.ActionListener() {
  355. public void actionPerformed(java.awt.event.ActionEvent evt) {
  356. jMenuItem17ActionPerformed(evt);
  357. }
  358. });
  359. jMenu2.add(jMenuItem17);
  360.  
  361. jMenuItem18.setText("SubstanceTwilightLookAndFeel");
  362. jMenuItem18.addActionListener(new java.awt.event.ActionListener() {
  363. public void actionPerformed(java.awt.event.ActionEvent evt) {
  364. jMenuItem18ActionPerformed(evt);
  365. }
  366. });
  367. jMenu2.add(jMenuItem18);
  368.  
  369. jMenuItem19.setText("SubstanceNebulaLookAndFeel");
  370. jMenuItem19.addActionListener(new java.awt.event.ActionListener() {
  371. public void actionPerformed(java.awt.event.ActionEvent evt) {
  372. jMenuItem19ActionPerformed(evt);
  373. }
  374. });
  375. jMenu2.add(jMenuItem19);
  376.  
  377. jMenuItem20.setText("SubstanceModerateLookAndFeel");
  378. jMenuItem20.addActionListener(new java.awt.event.ActionListener() {
  379. public void actionPerformed(java.awt.event.ActionEvent evt) {
  380. jMenuItem20ActionPerformed(evt);
  381. }
  382. });
  383. jMenu2.add(jMenuItem20);
  384.  
  385. jMenuBar1.add(jMenu2);
  386.  
  387. setJMenuBar(jMenuBar1);
  388.  
  389. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  390. getContentPane().setLayout(layout);
  391. layout.setHorizontalGroup(
  392. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  393. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  394. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  395. .addGroup(layout.createSequentialGroup()
  396. .addGap(41, 41, 41)
  397. .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
  398. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  399. .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  400. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  401. .addComponent(IDNO_txt, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
  402. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  403. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
  404. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  405. .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
  406. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  407. .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
  408. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  409. .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
  410. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE)
  411. .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
  412. .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
  413. .addContainerGap()
  414. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  415. .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 812, Short.MAX_VALUE)
  416. .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 812, Short.MAX_VALUE))))
  417. .addContainerGap())
  418. );
  419. layout.setVerticalGroup(
  420. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  421. .addGroup(layout.createSequentialGroup()
  422. .addContainerGap()
  423. .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 237, javax.swing.GroupLayout.PREFERRED_SIZE)
  424. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  425. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  426. .addComponent(IDNO_txt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  427. .addComponent(jButton3)
  428. .addComponent(jLabel6)
  429. .addComponent(jButton1)
  430. .addComponent(jButton5)
  431. .addComponent(jButton2)
  432. .addComponent(jButton4)
  433. .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  434. .addGap(18, 18, 18)
  435. .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE)
  436. .addContainerGap(17, Short.MAX_VALUE))
  437. );
  438.  
  439. pack();
  440. }// </editor-fold>
  441.  
  442. private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {
  443. try{
  444. UIManager.setLookAndFeel(new MotifLookAndFeel());
  445. SwingUtilities.updateComponentTreeUI(this);
  446. }catch(Exception ex){}
  447. }
  448.  
  449. private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {
  450. try{
  451. UIManager.setLookAndFeel(new NimbusLookAndFeel());
  452. SwingUtilities.updateComponentTreeUI(this);
  453. }catch(Exception ex){} // TODO add your handling code here:
  454. }
  455.  
  456. private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {
  457. try{
  458. UIManager.setLookAndFeel(new WindowsClassicLookAndFeel());
  459. SwingUtilities.updateComponentTreeUI(this);
  460. }catch(Exception ex){}
  461. }
  462.  
  463. private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {
  464. try{
  465. UIManager.setLookAndFeel(new WindowsLookAndFeel());
  466. SwingUtilities.updateComponentTreeUI(this);
  467. }catch(Exception ex){} // TODO add your handling code here:
  468. }
  469.  
  470. private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {
  471. try{
  472. UIManager.setLookAndFeel(new HiFiLookAndFeel());
  473. SwingUtilities.updateComponentTreeUI(this);
  474. }catch(Exception ex){} // TODO add you()r handling code here:
  475. }
  476.  
  477. private void jMenuItem11ActionPerformed(java.awt.event.ActionEvent evt) {
  478. try{
  479. UIManager.setLookAndFeel(new GraphiteLookAndFeel());
  480. SwingUtilities.updateComponentTreeUI(this);
  481. }catch(Exception ex){} // TODO add your handling code here:
  482. }
  483.  
  484. private void jMenuItem12ActionPerformed(java.awt.event.ActionEvent evt) {
  485. try{
  486. UIManager.setLookAndFeel(new FastLookAndFeel());
  487. SwingUtilities.updateComponentTreeUI(this);
  488. }catch(Exception ex){}
  489. }
  490.  
  491. private void jMenuItem13ActionPerformed(java.awt.event.ActionEvent evt) {
  492. try{
  493. UIManager.setLookAndFeel(new AluminiumLookAndFeel());
  494. SwingUtilities.updateComponentTreeUI(this);
  495. }catch(Exception ex){}
  496. }
  497.  
  498. private void jMenuItem14ActionPerformed(java.awt.event.ActionEvent evt) {
  499. try{
  500. UIManager.setLookAndFeel(new AeroLookAndFeel());
  501. SwingUtilities.updateComponentTreeUI(this);
  502. }catch(Exception ex){} // TODO add your handling code here:
  503. }
  504.  
  505. private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {
  506. try{
  507. UIManager.setLookAndFeel(new NimRODLookAndFeel());
  508. SwingUtilities.updateComponentTreeUI(this);
  509. }catch(Exception ex){} // TODO add your handling code here:
  510. }
  511.  
  512. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  513. try{
  514. String findtype;
  515. if(jComboBox1.getSelectedItem().toString().equals("IDNO")){
  516. findtype = "IDNO";
  517. }else{
  518. findtype = "FirstName";
  519. }
  520. stmt = conn.createStatement();
  521. int row = tableview.getRowCount();
  522. while(row > 0) {
  523. row--;
  524. tableview.removeRow(row);
  525. }
  526. ResultSet view = (ResultSet) stmt.executeQuery("select * from products where "+findtype+" like '"+IDNO_txt.getText()+"%'");
  527.  
  528. ResultSetMetaData md = (ResultSetMetaData) view.getMetaData();
  529. int colcount = md.getColumnCount();
  530.  
  531. Object[] data = new Object[colcount];
  532.  
  533. while (view.next()) {
  534. for (int i=1; i<=colcount; i++) {
  535. data[i-1] = view.getString(i);
  536. }
  537. tableview.addRow(data);
  538. }
  539. jScrollPane1.setViewportView(jTable1);
  540. }catch(Exception e) {System.out.println(e);
  541. }
  542. }
  543.  
  544. private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {
  545. try{
  546. Runtime.getRuntime().exec("cmd /c start http:j4guiang.blogspot.com/");
  547. }catch(Exception e){}
  548. }
  549.  
  550. private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
  551. try{
  552. Runtime.getRuntime().exec("cmd /c start http://j4guiang-mailing-list.2303136.n4.nabble.com/");
  553. }catch(Exception e){}
  554. }
  555.  
  556. private void jMenuItem15ActionPerformed(java.awt.event.ActionEvent evt) {
  557. try{
  558. UIManager.setLookAndFeel(new SubstanceMagmaLookAndFeel());
  559. SwingUtilities.updateComponentTreeUI(this);
  560. }catch(Exception ex){} // TODO add your handling code here:
  561. }
  562.  
  563. private void jMenuItem16ActionPerformed(java.awt.event.ActionEvent evt) {
  564. try{
  565. UIManager.setLookAndFeel(new SubstanceEmeraldDuskLookAndFeel());
  566. SwingUtilities.updateComponentTreeUI(this);
  567. }catch(Exception ex){} // TODO add your handling code here:
  568. }
  569.  
  570. private void jMenuItem17ActionPerformed(java.awt.event.ActionEvent evt) {
  571. try{
  572. UIManager.setLookAndFeel(new SubstanceNebulaBrickWallLookAndFeel());
  573. SwingUtilities.updateComponentTreeUI(this);
  574. }catch(Exception ex){}
  575. }
  576.  
  577. private void jMenuItem18ActionPerformed(java.awt.event.ActionEvent evt) {
  578. try{
  579. UIManager.setLookAndFeel(new SubstanceTwilightLookAndFeel());
  580. SwingUtilities.updateComponentTreeUI(this);
  581. }catch(Exception ex){}
  582. }
  583.  
  584. private void jMenuItem19ActionPerformed(java.awt.event.ActionEvent evt) {
  585. try{
  586. UIManager.setLookAndFeel(new SubstanceNebulaLookAndFeel());
  587. SwingUtilities.updateComponentTreeUI(this);
  588. }catch(Exception ex){}
  589. }
  590.  
  591. private void jMenuItem20ActionPerformed(java.awt.event.ActionEvent evt) {
  592. try{
  593. UIManager.setLookAndFeel(new SubstanceModerateLookAndFeel());
  594. SwingUtilities.updateComponentTreeUI(this);
  595. }catch(Exception ex){} // TODO add your handling code here:
  596. }
  597.  
  598. private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {
  599. InstallDatabase();
  600. }
  601.  
  602. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
  603. if(Gender_cmb.getSelectedItem().toString().equals("Choose one")){
  604. JOptionPane.showMessageDialog(null,"Please select Gender");
  605. }else{
  606. try{
  607. stmt.executeUpdate("insert into tblregistration(FirstName,LastName,Gender,Course,YearLevel)values('"+FirstName_txt.getText()+
  608. "','"+LastName_txt.getText()+"','"+Gender_cmb.getSelectedItem()+"',"
  609. + "'"+Course_cmb.getSelectedItem()+"','"+YearLevel_cmb.getSelectedItem()+"')");
  610. rs = stmt.executeQuery("select * from tblregistration where FirstName='"+FirstName_txt.getText()+"' and LastName='"+LastName_txt.getText()+"'"
  611. + " and Gender='"+Gender_cmb.getSelectedItem()+"' and Course='"+Course_cmb.getSelectedItem()+"' "
  612. + " and YearLevel='"+YearLevel_cmb.getSelectedItem()+"'");
  613. while(rs.next()){
  614. System.out.println(rs.getString("IDNO"));
  615. JOptionPane.showMessageDialog(null,"Record successfuly Save: \n Your IDNO:"+rs.getString("IDNO"));
  616. }
  617. }catch(Exception e){
  618. JOptionPane.showMessageDialog(null,e);
  619. }
  620. }
  621. }
  622.  
  623. private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
  624. try{
  625. stmt.executeUpdate("delete from tblregistration where IDNO='"+IDNO_txt.getText()+"'");
  626. JOptionPane.showMessageDialog(null,"Record successfuly deleted");
  627. }catch(Exception e){
  628. JOptionPane.showMessageDialog(null,e);
  629. }
  630. }
  631.  
  632. private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
  633. try{
  634. stmt.executeUpdate("update tblregistration set FirstName='"+FirstName_txt.getText()+"',"
  635. + "LastName='"+LastName_txt.getText()+"',Gender='"+Gender_cmb.getSelectedItem()+"',"
  636. + "Course='"+Course_cmb.getSelectedItem()+"',YearLevel='"+YearLevel_cmb.getSelectedItem()+"' where IDNO='"+IDNO_txt.getText()+"'");
  637. JOptionPane.showMessageDialog(null,"Update successful");
  638. }catch(Exception e){
  639. JOptionPane.showMessageDialog(null,e);
  640. }
  641. }
  642.  
  643. private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
  644. LastName_txt.setText(null);
  645. FirstName_txt.setText(null);
  646. IDNO_txt.setText(null);
  647. }
  648.  
  649. private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
  650. try{
  651. Runtime.getRuntime().exec("cmd /c start http://j4guiang.blogspot.com/2011/10/java-mysql-basic-with-gui.html");
  652. }catch(Exception e){} // TODO add your handling code here:
  653. }
  654. public static void main(String args[]) {
  655. java.awt.EventQueue.invokeLater(new Runnable() {
  656. public void run() {
  657. new NewJFrame().setVisible(true);
  658. }
  659. });
  660. }
  661. // Variables declaration - do not modify
  662. private javax.swing.JComboBox Course_cmb;
  663. private javax.swing.JTextField FirstName_txt;
  664. private javax.swing.JComboBox Gender_cmb;
  665. private javax.swing.JTextField IDNO_txt;
  666. private javax.swing.JTextField LastName_txt;
  667. private javax.swing.JComboBox YearLevel_cmb;
  668. private javax.swing.JButton jButton1;
  669. private javax.swing.JButton jButton2;
  670. private javax.swing.JButton jButton3;
  671. private javax.swing.JButton jButton4;
  672. private javax.swing.JButton jButton5;
  673. private javax.swing.JComboBox jComboBox1;
  674. private javax.swing.JLabel jLabel1;
  675. private javax.swing.JLabel jLabel2;
  676. private javax.swing.JLabel jLabel3;
  677. private javax.swing.JLabel jLabel4;
  678. private javax.swing.JLabel jLabel5;
  679. private javax.swing.JLabel jLabel6;
  680. private javax.swing.JMenu jMenu1;
  681. private javax.swing.JMenu jMenu2;
  682. private javax.swing.JMenuBar jMenuBar1;
  683. private javax.swing.JMenuItem jMenuItem1;
  684. private javax.swing.JMenuItem jMenuItem10;
  685. private javax.swing.JMenuItem jMenuItem11;
  686. private javax.swing.JMenuItem jMenuItem12;
  687. private javax.swing.JMenuItem jMenuItem13;
  688. private javax.swing.JMenuItem jMenuItem14;
  689. private javax.swing.JMenuItem jMenuItem15;
  690. private javax.swing.JMenuItem jMenuItem16;
  691. private javax.swing.JMenuItem jMenuItem17;
  692. private javax.swing.JMenuItem jMenuItem18;
  693. private javax.swing.JMenuItem jMenuItem19;
  694. private javax.swing.JMenuItem jMenuItem2;
  695. private javax.swing.JMenuItem jMenuItem20;
  696. private javax.swing.JMenuItem jMenuItem3;
  697. private javax.swing.JMenuItem jMenuItem4;
  698. private javax.swing.JMenuItem jMenuItem5;
  699. private javax.swing.JMenuItem jMenuItem6;
  700. private javax.swing.JMenuItem jMenuItem7;
  701. private javax.swing.JMenuItem jMenuItem8;
  702. private javax.swing.JMenuItem jMenuItem9;
  703. private javax.swing.JPanel jPanel1;
  704. private javax.swing.JScrollPane jScrollPane1;
  705. private javax.swing.JTable jTable1;
  706. // End of variables declaration
  707.  
  708. private void InstallDatabase() {
  709. try{
  710. Class.forName("com.mysql.jdbc.Driver");
  711. url = "jdbc:mysql://localhost/";
  712. conn = DriverManager.getConnection(url,"root","");
  713. stmt = conn.createStatement();
  714. stmt.executeUpdate("create database registration");
  715. stmt.executeUpdate("use registration");
  716. url = "jdbc:mysql://localhost/registration";
  717. conn = DriverManager.getConnection(url,"root","");
  718. stmt.executeUpdate("create table tblregistration(IDNO int primary key auto_increment,"
  719. + "FirstName varchar(30),LastName varchar(30),Gender varchar(10),Course varchar(20),"
  720. + "YearLevel varchar(20))");
  721. JOptionPane.showMessageDialog(null,"Installing database successfull.\n"
  722. + "click ok \nand run this application again.");
  723. System.exit(0);
  724. }catch(Exception f){
  725. JOptionPane.showMessageDialog(null,f);
  726. }
  727. }
  728. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement