0

I currently have an application with a single window builder and multiple JFrames. When i move from one jframe to another i use the following code

contentPane.setVisible(false);
EditAccountDetails editAccountDetails = new EditAccountDetails("admin");
editAccountDetails.setVisible(true);

This creates a new jframe but this doesnt close the old one. This doesnt happen when i move from my windowbuilder to a jframe, because i can close the window builder frame:

frame.dispose();
AdminDashboard adminDashboard = new AdminDashboard();
adminDashboard.setVisible(true);

I cant close the jframe in the same way, and im assuming i shouldnt have multiple instances of a windowbuilder. How do i fix this issue?

enter image description here

rohaldb
  • 589
  • 7
  • 24

1 Answers1

2

I cant close the jframe in the same way

Why not? dispose is a method of JFrame

and im assuming i shouldnt have multiple instances of a windowbuilder.

The Use of Multiple JFrames, Good/Bad Practice? might provide more information

How do i fix this issue?

I'd recommend using a CardLayout instead, see How to Use CardLayout for more details.

I'd also recommend not using Window Builder or any other GUI editor into you have a better understanding of how the API works, but that's just me

Community
  • 1
  • 1
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
  • 1
    *"..recommend not using Window Builder or any other GUI editor into you have a better understanding of how the API works, but that's just me"* Nope. You are not alone there. – Andrew Thompson May 15 '16 at 07:22