How do I clear my entire application view area

Hi,

I have an application I have created where I wish to create a "restart" process and simply clear out all the visible screen area and start completely over from scratch.

Is there a simple command that will accomplish this or do I need to clear all the objects individually?

Would deleting all the layouts and panels accomplish this?

Thanks,

Chris
Christopher ScheneSystem Engineer/Software EngineerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
zzynxConnect With a Mentor Software engineerCommented:
>> Is there a simple command that will accomplish this?
If you're talking about a JInternalFrame, try calling:
yourInternalFrame.getContentPane().removeAll();

Open in new window


>> Would deleting all the layouts and panels accomplish this?
You just have to remove the child items from your highest level panel by calling removeAll();

Eg. If you have built up your panel like this:

JPanel innerPnl1 = new JPanel();
// Here you're adding several panels or other controls to innerPnl1
JPanel innerPnl2 = new JPanel();
// Here you're adding several panels or other controls to innerPnl2

JPanel yourHighestLevelPanel = new JPanel(new BorderLayout());
yourHighestLevelPanel.add(innerPnl1, BorderLayout.NORTH);
yourHighestLevelPanel.add(innerPnl2, BorderLayout.CENTER);

Open in new window

All you have to do is:
yourHighestLevelPanel.removeAll();

Open in new window

0
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
What sort of application are we talking about here? My guess is Swing but let me know if that assumption is incorrect. If you could provide some code it would help.

Do you mean that you want to be able to clear out all user input from fields, etc or do you want to totally remove all fields controls from the window?
0
 
Christopher ScheneSystem Engineer/Software EngineerAuthor Commented:
The code is on my work PC. I'll grab a snippet and post it.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Christopher ScheneSystem Engineer/Software EngineerAuthor Commented:
Of course since it is company software, I need obfuscate somethings.
0
 
Christopher ScheneSystem Engineer/Software EngineerAuthor Commented:
Thanks
0
 
zzynxSoftware engineerCommented:
You're welcome.
Thanx 4 axxepting.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.