Solved

How do I clear my entire application view area

Posted on 2015-02-13
6
96 Views
Last Modified: 2015-02-18
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
0
Comment
Question by:cschene
  • 3
  • 2
6 Comments
 
LVL 35

Expert Comment

by:mccarl
ID: 40609279
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
 

Author Comment

by:cschene
ID: 40610134
The code is on my work PC. I'll grab a snippet and post it.
0
 

Author Comment

by:cschene
ID: 40610500
Of course since it is company software, I need obfuscate somethings.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 37

Accepted Solution

by:
zzynx earned 500 total points
ID: 40614386
>> 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
 

Author Closing Comment

by:cschene
ID: 40615814
Thanks
0
 
LVL 37

Expert Comment

by:zzynx
ID: 40616015
You're welcome.
Thanx 4 axxepting.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to implement Singleton Design Pattern in Java.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now