Solved

setVisible(false) - how can I show it again

Posted on 2004-09-28
7
220 Views
Last Modified: 2010-03-31
I've got a Java Application that extends Frame.

At a certain point, I want to hide it without showing it on the taskbar so I setVisble to false.  Is there a way to get it back?  If possible, I'd like to use a icon on the desktop, double click it and show the window again.
0
Comment
Question by:mcgirk
7 Comments
 
LVL 4

Expert Comment

by:JK2429
Comment Utility
Yes.  Set up a boolean value.
After minimizing, if you click on the icon, it would execute the function which will make your window appear again thus as you click on the icon, your boolean value is set to true.
0
 

Author Comment

by:mcgirk
Comment Utility
What does the icon point to?
The only thing I can think of is to make it a batch file and run a java command?  Can you give me an example?
0
 
LVL 3

Expert Comment

by:CI-Ia0s
Comment Utility
You could make a JAR file with a class that sets visibility to true; however, you'd need to use sockets or CORBA to accomplish this. It'd be much better if you could keep it in one program (another frame perhaps, a timer, etc.).
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 92

Accepted Solution

by:
objects earned 50 total points
Comment Utility
you could display a dialog when the frame was hidden with a button to redisplay the frame (and hide the dialog)
0
 
LVL 3

Expert Comment

by:CI-Ia0s
Comment Utility
If you wanted to be really utilitarian (and take up as little screen space as possible),  you could create a frame and give it a window destroyer method that sets the first frame to be visible:

In your main class:

JFrame tempFrame = new JFrame();
tempFrame.setSize(1,1);
WinListener winListener = new WinListener();
tempFrame.addWindowListener(winListener);
tempFrame.setVisible(true);

Class WinListener:

import java.awt.*;
import java.awt.event.*;

public class WinListener extends WindowAdapter{

public void windowClosing(WindowEvent evt){
MainClass.invisibleFrame.setVisible(true);
}
}

NOTES: MainClass is the name of the main class and invisibleFrame is the name of the frame to make visible. invisibleFrame has to be declared outside of a method for this to work (i.e. globally).
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
that will show the frame in the task bar.
0
 
LVL 3

Expert Comment

by:CI-Ia0s
Comment Utility
Hrmm... good point (but would it matter in this case? Isn't it only the hidden frame that needs to stay out of the taskbar?). My problem with a dialog is that he may be trying to run some other tasks while the frame is hidden which would require him to make a new thread (which while not very hard as you've taught me, could be a bit annoying if not necessary...).
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

772 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

12 Experts available now in Live!

Get 1:1 Help Now