Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- String user=txtUsername.getText();
- char[] pass=txtPassword.getPassword();
- if(user == null){
- JOptionPane.showMessageDialog(null,"Username Field is empty");
- }
- else if(pass==null){
- JOptionPane.showMessageDialog(null,"Password Field is empty");
- }
- else{
- String sql="select * from account where username=? and password=?";
- try{
- pst=conn.prepareStatement(sql);
- pst.setString(1,txtUsername.getText());
- pst.setString(2,txtPassword.getText());
- rs=pst.executeQuery();
- if(rs.next()){
- GridlockMain a=new GridlockMain();
- a.setVisible(true);
- }
- else{
- JOptionPane.showMessageDialog(null,"Your Username or Password is incorrect");
- txtUsername.setText(null);
- txtPassword.setText(null);
- }
- }
- catch(SQLException e){
- JOptionPane.showMessageDialog(null,e);
- }
- String user=txtUsername.getText();// It return empty String ""
- // even no data is entered.
- if(user.isEmpty){
- JOptionPane.showMessageDialog(null,"Username Field is empty");
- }
- ......
- if(!user.length() > 0){
- JOptionPane.showMessageDialog(null,"Username Field is empty");
- }
- else if(!pass.length > 0){
- JOptionPane.showMessageDialog(null,"Password Field is empty");
- }
- txtUsername.getText().equals("");
- if (user.length() < 0) {
- JOptionPane.showMessageDialog(null,"Username Field is empty");
- }
- else if(pass.length() < 0) {
- JOptionPane.showMessageDialog(null,"Password Field is empty");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement