I am creating a program that has a switch user feature, so basically I have two frames, log in frame and the main frame. The problem is, after I log in using the switch user feature the second time, my main frame gets so messy.
Here's my code for log in frame
if(e.getActionCommand().equals("Log In")){
        try {
            rs.absolute(0);
            while(rs.next()){
                if(rs.getString("Username").equals(login.usert.getText()) && rs.getString("Password").equals(login.passt.getText())){
                    rs = st.executeQuery("select * from employee where Email ='"+login.usert.getText()+"'");
                    while(rs.next()){
                        if(rs.getString("Email").equals(login.usert.getText())){
                            eid = rs.getInt("EID");
                            new gui().user.setText("User" + rs.getString("Nickname"));
                            login.frame.dispose();
                            break;
                        }   
                    }
                }
                else{
                    login.error.setText("Invalid username/password");
                }
            }
        } catch (SQLException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
Here's my code for switch user button
ubutton.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e) {
            mainFrame.dispose();
            login.frame.setVisible(true);
        }
    });
thanks in advance!


 
    