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");
- }
- //Validate whether user Has input some information:
- if(UserNameTA.getText() == null || UserNameTA.getText().trim().isEmpty())
- {
- btnEnter.setEnabled(false);
- }
- else
- {
- //Make a new JFrame for login
- new ProfileHome().setVisible(true);
- frame.dispose();
- }
- btnEnter.setEnabled(true);
- StringUtils.isEmpty(txtUsername.getText())
- String user = txtUsername.getText();
- String pw = txtPassword.getText();
- if(user.isEmpty() || (pw.isEmpty()))
- {
- JOptionPane.showMessageDialog(null, "Your Username or Password is incorrect" );
- }
- else
- {
- //proceed to query
- if (user.length() == 0) {
- JOptionPane.showMessageDialog(null, "Username Field is empty");
- } else if (pass.length() == 0) {
- JOptionPane.showMessageDialog(null, "Password Field is empty");
- }
Add Comment
Please, Sign In to add comment