Solved

How do I clear my entire application view area

Posted on 2015-02-13
6
102 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:Christopher Schene
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 36

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:Christopher Schene
ID: 40610134
The code is on my work PC. I'll grab a snippet and post it.
0
 

Author Comment

by:Christopher Schene
ID: 40610500
Of course since it is company software, I need obfuscate somethings.
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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:Christopher Schene
ID: 40615814
Thanks
0
 
LVL 37

Expert Comment

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

734 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