Click here to Skip to main content
Sign Up to vote bad
good
See more: JavaSwing
My program has two windows. Lets call them Window A and Window B.
 
When the user loads up the program Window A appears which lets the user load up a .txt file. This .txt file contains
important data for Window B to work correctly. When the .txt file is loaded, the user clicks on a button and Window B loads up and using the data from the .txt file from Window A to correctly display.
 
No problem.
 
The problem comes when I want to use a different .txt file. On Window B I have a button which loads up Window A again to let the user type in different values. When the user clicks on the button to load Window B up again all my swing components don't display correctly. In Window B I use a BorderLayout, so when I reload Window B with the new values the right hand side of the BorderLayout seems to disappear. I think that what my program is doing is reloading all the component on-top of each other which is why it providing strange results and I am just wondering how I can rectify this issue.
 
The problem doesn't lie with the new values from the .txt files, as the values from .txt file doesn't interact with the swing components.
 
Here is the code I have when loading Window A from Window B to let the user type in different values.
 
WindowA.startFrame.setVisible(true);
WindowB.guiFrame.invalidate();
WindowB.guiFrame.dispose();
Posted 19 Feb '12 - 21:46


2 solutions

Just removed all the components from the Jpanel.
Not the best of solutions but it works.
  Permalink  
I assume you're trying to create the components newly. that results in a overloaded GUI with to much components to be shown. so some of them are rendered in positions that you cannot see - behind other components or outside the frame area.
 
How about just changing a the JPanel in a constant JFrame? You could dispose the non valid JPanel and create a new fresh one.
 
Also do you have a facade for the data?? You should have one, it's much easier to create the components with the new values from scratch.
  Permalink  
Comments
Willtwinny - 24 Feb '12 - 9:46
guiFrame is a JFrame, and when I call: WindowB.guiFrame.dispose(); doesn't seem to dispose the JFrame.
Willtwinny - 24 Feb '12 - 10:08
I have solved it. I just removed all the components when closing down the JPanel. Not the best of solutions but it now works.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 414
1 Arun Vasu 253
2 OriginalGriff 190
3 CPallini 163
4 Aarti Meswania 158
0 Sergey Alexandrovich Kryukov 10,169
1 OriginalGriff 7,749
2 CPallini 4,181
3 Rohan Leuva 3,482
4 Maciej Los 3,089


Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 24 Feb 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid