public void actionPerformed(ActionEvent ae) { if (ae.getSource() == b1) { try { Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "system", "123"); PreparedStatement ps = con.prepareStatement("select * from LoginForm where username=? and password=?"); String UserName = t1.getText(); String Password = jp1.getText(); ps.setString(1, UserName); ps.setString(2, Password); ResultSet rs = ps.executeQuery(); boolean flag = rs.next(); if (flag) { new Main(); f.setVisible(false); } else { JOptionPane.showMessageDialog(null, "Please Enter valid Name And Password"); } } catch (Exception e) { System.out.println("Error:" + e); } } else if (ae.getSource() == b2) { t1.setText(""); jp1.setText(""); } else if (ae.getSource() == b3) { f.setVisible(false); } }
public void actionPerformed(ActionEvent e) { p2.str1 = fn1.getText(); p2.str2 = ln1.getText(); p2.str3 = un1.getText(); p2.str4 = ps11.getText(); p2.str5 = eid1.getText(); p2.str6 = ps21.getText(); p2.str7 = mb1.getText(); p2.str8 = cct1.getText(); p2.str9 = hquali1.getText(); p2.str10 = dober1.getText(); p2.str11 = dober2.getText(); p2.str12 = dober3.getText(); p2.str13 = p2.str10 + "/" + p2.str11 + "/" + p2.str12; boolean bl1, bl2, bl3, bl4, bl5, bl6, bl7, bl8, bl9; bl1 = false; bl2 = false; bl3 = false; bl4 = false; bl5 = false; bl6 = false; bl7 = false; bl8 = false; if (str1.length() > 0) { // er1.setForeground(null); er1.setText(""); fn1.setBorder(BorderFactory.createLineBorder(Color.GRAY)); bl1 = true; repaint(); } else { er1.setForeground(Color.red); er1.setText("(First name can't be null)"); fn1.setBorder(BorderFactory.createLineBorder(Color.red)); repaint(); } if (str3.length() > 0) { er3.setText(""); un1.setBorder(BorderFactory.createLineBorder(Color.GRAY)); bl2 = true; repaint(); } else { er3.setForeground(Color.red); er3.setText("(Username can't be null)"); un1.setBorder(BorderFactory.createLineBorder(Color.red)); repaint(); } if (str5.length() > 0) { er6.setText(""); eid1.setBorder(BorderFactory.createLineBorder(Color.GRAY)); bl3 = true; repaint(); } else { er6.setForeground(Color.red); er6.setText("(email id can't be null)"); eid1.setBorder(BorderFactory.createLineBorder(Color.red)); repaint(); } if (str4.length() > 0) { er4.setText(""); ps11.setBorder(BorderFactory.createLineBorder(Color.GRAY)); bl4 = true; repaint(); } else { er4.setForeground(Color.red); er4.setText("(Password can't be null)"); ps11.setBorder(BorderFactory.createLineBorder(Color.red)); repaint(); } if ((str4.equals(str6))) { str6 = str4; er5.setForeground(null); er5.setText(""); ps21.setBorder(BorderFactory.createLineBorder(Color.GRAY)); bl5 = true; repaint(); } else { er5.setForeground(Color.red); er5.setText("(both pwd should be same)"); ps21.setBorder(BorderFactory.createLineBorder(Color.red)); repaint(); } if (str7.length() == 10) { er7.setText(""); mb1.setBorder(BorderFactory.createLineBorder(Color.GRAY)); bl6 = true; repaint(); } else { er7.setForeground(Color.red); er7.setText("(number should be of 10 digit)"); mb1.setBorder(BorderFactory.createLineBorder(Color.red)); repaint(); } if (str8.length() > 0) { er8.setText(""); cct1.setBorder(BorderFactory.createLineBorder(Color.GRAY)); bl7 = true; repaint(); } else { er8.setForeground(Color.red); er8.setText("(Current City can't be null)"); cct1.setBorder(BorderFactory.createLineBorder(Color.red)); repaint(); } if (str9.length() > 0) { er9.setText(""); hquali1.setBorder(BorderFactory.createLineBorder(Color.GRAY)); bl8 = true; repaint(); } else { er9.setForeground(Color.red); er9.setText("(Highest Qualif. can't be null)"); hquali1.setBorder(BorderFactory.createLineBorder(Color.red)); repaint(); } try { if ((bl1 && bl2 && bl3 && bl4 && bl5 && bl6 && bl7 && bl8) == true) { JOptionPane.showMessageDialog(null, "Data submitting "); p2.goer(); } } catch (Exception e3) { } }