Solved

setVisible(false) - how can I show it again

Posted on 2004-09-28
7
227 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
ID: 12174104
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
ID: 12174148
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
ID: 12174798
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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 12174946
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
ID: 12175774
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
ID: 12175799
that will show the frame in the task bar.
0
 
LVL 3

Expert Comment

by:CI-Ia0s
ID: 12175833
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java Jpanels and Jframe 8 33
eclipse java  build path 6 56
Should localization be done inside spring controller 5 25
How do I remove an object from a 3 24
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 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:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

776 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