Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Moving frome one GUI to the Next  RSS feed

 
Geoff Jefferson
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

The first interface my user sees is implemented with JFrame ( call it FrameOne) .
From here user clicks a button that implements another GUI using JFrame ( call it FrameTwo ).

While in FrameTwo the user makes a selection and clicks a button that should somehow
re-paint FrameOne with the updated data, or, get rid of FrameOne, and create FrameTwo
with new data.

Currently, I'm creating a new instance of FrameOne with updated data, which isn't so bad,
except for the fact that the first instance is in the back ground.

My question is. Upon creation of FrameTwo should I be looking at how to get rid of FrameOne,
and instantiate the second instance of FrameOne with new data upon button click.

Or,

Should I be looking to somehow update the original FrameOne with new data?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are looking for a good user experience, i.e. the data in the frame just changes instead of the frame vanishing and a new frame appearing, then changing the data in the frame would be the way to go.
 
Geoff Jefferson
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to move to the second frame in order make the selection because there is already enough going on in the first frame.
My problem is that I don't know how to 'refresh' the original frame.

So, in retrospect my question should read....How does one refresh the first frame to reflect the changes made in the first?

Thanks.

 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out CardLayout. You create each "frame" first, then add them as separate cards. The next button than a) switches cards (CardLayout has a next method) and b) copy data from one to the other.
You will need to keep a reference to the container (JPanel mostly) that has the CardLayout because it is required as a parameter for the CardLayout methods.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!