Solved

How do I clear my entire application view area

Posted on 2015-02-13
6
97 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSum5 challenge 5 84
split string containing \r\n in Java 46 43
web application structure 18 76
by zero exception 10 39
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

785 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