Header Ads

Create Employee Management System using JAVA with SQLite - Part 08

How to close previous jframe on the opening of a new jframe in netbeans
Up to now when you are logging into the program by running Login_jframe.java file, it will not close after appearing the next windows. Actually we don’t want the login page after viewing the second page when logging has successfully done. So we need a method to close login page. Please follow step by step carefully otherwise you don’t able to get the right output. 












Add this method into Login-jframe.java file.
public void close(){
        WindowEvent winClosingEvent = new WindowEvent(this,WindowEvent.WINDOW_CLOSING);
        Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(winClosingEvent);
    }

Then you need to import these codes too.
import java.awt.*;
import java.awt.event.*;
Now go to this part to add your close() method












But the program is not completed yet. You have to make a change in the panel of login file. Go to Login_jframe.java file à Design à right click on the panel  à Properties. The top of the properties list you can see ‘defaultCloseOperation’ marked as EXIT_ON_CLOSE. Change it to DISPOSE à Close.

Now you can run the program, then you can see after login by setting right username and password, it will automatically close the windows and open Employee_info.java file.

In next part we will discuss about ‘how to get values into the text field when click on the jtable’ by using Java. If you have any doubts about the part – 08 please don’t hesitate to ask from iTech Digest | Thank you! See you on part - 09

No comments

Thank you very much for your ideas!