I have a login form that doesn't hide when a user logs in successfully. what might be the problem?
code
package employeeinformationandpayrollsystem;
import javax.swing.*;
import javax.swing.ImageIcon.*;
import javax.swing.JPanel.*;
import javax.swing.JOptionPane;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import javax.swing.border.*;
import java.sql.*;
public class UserLogin implements ActionListener,WindowListener
{
JButton ok,cancel;
String userId,password,status;
JPasswordField passwordInput;
JTextField f1,f2;
boolean flag=false;
String pass1="admin";
String pass2="muthee";
//char englishStr[]={'m','u','t','h','e','e'};
//char urduStr[]={'j','o','n','n','y'};
static JFrame aWindow=new JFrame("UserLOGIN ");
public UserLogin(String title)
{
aWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CL OSE);
Toolkit theKit=aWindow.getToolkit();
Dimension wndSize=theKit.getScreenSize();
aWindow.setBounds(wndSize.width/4,wndSize.height/4,wndSize.width/2,wndSize.height/2);
FlowLayout flow=new FlowLayout();
Container content=aWindow.getContentPane();
content.setLayout(flow);
JLabel l1=new JLabel("USER NAME");
f1=new JTextField(userId);
JLabel l2=new JLabel("PASSWORD");
passwordInput=new JPasswordField(password);
JLabel l3=new JLabel("Status");
f2=new JTextField(status);
ok=new JButton("OK");
cancel=new JButton("Cancel");
Dimension size=new Dimension(80,20);
f1.setPreferredSize(size);
passwordInput.setPreferredSize(size);
f2.setPreferredSize(size);
content.add(l1);
content.add(f1);
content.add(l2);
content.add(passwordInput);
//content.add(l3);
content.add(f2);
content.add(l3);
content.add(ok);
content.add(cancel);
aWindow.setVisible(true);
//f1.addActionListener(this);
passwordInput.addActionListener(this);
ok.addActionListener(this);
cancel.addActionListener(this);
aWindow.addWindowListener(this);
}//end of constructor
/*public void keyPressed(KeyEvent ke)
{
for(int ii=0;ii<35;ii++)
{
if (ke.getKeyCode()==englishStr[ii])
{
f1.append(String.valueOf(urduStr[ii]));
}
}
}
public void keyReleased(KeyEvent ke){
}
public void keyTyped(KeyEvent ke){
//System.out.println("key is pressed");
}*/
//handler for window closing event
public void windowClosing(WindowEvent e)
{
aWindow.dispose();
}
//listener interface functions we must implement
public void windowOpened(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void actionPerformed(ActionEvent ae)
{
Object source=ae.getSource();
if (ae.getActionCommand().equals("Cancel")||source==c ancel)
{
System.exit(0);
}
else if(ae.getActionCommand().equals("OK")||source==ok)
{
//textfieldPas
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String sourceURL="jdbcdbc:database";
Connection databaseConnection=DriverManager.getConnection(sou rceURL);
Statement statement=databaseConnection.createStatement();
String str = "SELECT User,Password FROM Login WHERE user='" + f1.getText() + "' AND password='" + passwordInput.getText() + "'AND status='"+f2.getText()+"'";
ResultSet authorNames=statement.executeQuery(str);
if (authorNames.next())
{
switch (f2.getText()) {
case "admin":
UserChoice us=new UserChoice("Admin choice");
break;
case "user":
UserChoice1 us1=new UserChoice1("User Choice");
break;
}
}
else {
JOptionPane.showMessageDialog(null,"Invalid Password/User Name/Status");
}
}
catch(Exception cnfe)
{
System.err.println(cnfe);
}
}
}
//action performed
public static void main(String arg[])
{
UserLogin lola=new UserLogin("User Login");
}
}//UserLogin end}//UserLogin end