I am new to Java language.In my project i created a JInternalFrame inside a JDesktopPane that include in the JFrame(A). In that JInternalFrame i created a button that open another JFrame(B). So what i want is when I am clicking the button the Previous JFrame(A) must dispose.
I tried to create an object of JFrame(A) and use dispose method. But it's not working.
This is the code in JFrame(A)
private void panelProfileMouseClicked(java.awt.event.MouseEvent evt) {
DBConnection connection = new DBConnection();
connection.getData(username);
Profile profile = new Profile(connection.firstname,connection.lastname,connection.gender,connection.password); //Calling JInternalFrame
smallDesktop.removeAll();
smallDesktop.add(profile).setVisible(true);
}
This is the code in JInternalFrame that calls other JFrame(B)
private void btnChangePasswordActionPerformed(java.awt.event.ActionEvent evt) {
new ChangePassword().setVisible(true);
}
As the comment you got earlier, it is surely true that you didn't clarify it properly. But I think what you can do is to use
System.Exit(0);instead ofdispose