I am trying to create a very simple Java GUI but I have run into an issue. I have 2 panels: 1 which adds data and the other that views it. I was using card layout but realized it does not update the data on the panels when switching between them. So I am trying to figure out which is the best approach to switching between JPanels who data will constantly be updating.
Asked
Active
Viewed 91 times
1

Andrew Thompson
- 168,117
- 40
- 217
- 433

bardockyo
- 1,415
- 6
- 21
- 32
-
4The layout manager doesn't affect the updating. Your application is responsible for updating the data on the panel. So stick with the card layout and fix your application code to update the panel. – camickr May 02 '13 at 04:55
-
How would I update the panel after it has been created? – bardockyo May 02 '13 at 04:57
-
For better help sooner, post an [SSCCE](http://sscce.org/). – Andrew Thompson May 02 '13 at 04:59
-
You update the data of components on the panel. For example if you have a text field you would use the `setText(...)` method. Every Swing component has one or more methods that allow you to change the data of the component. We don't know what your application does or what components you use so we can't give specific advice. – camickr May 02 '13 at 05:00
-
Post your code for better understanding – prasanth May 02 '13 at 05:02
-
@bardockyo : Here is a related [example, using CardLayout](http://stackoverflow.com/a/13378672/1057230), which might can help you :-) – nIcE cOw May 02 '13 at 12:21