Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Swing / AWT / SWT and the fly likes How Donot open JFrame More then one time? please help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How Donot open JFrame More then one time? please help" Watch "How Donot open JFrame More then one time? please help" New topic
Author

How Donot open JFrame More then one time? please help

vijay Panner
Ranch Hand

Joined: Sep 29, 2010
Posts: 30
Hi,

I am developing one Desktop Application Using Swing. In my application, I designed Menu frame, whenever i click one menu_item respective page will load, suppose again i click same menu_item then one more same frame is opened.But i need only one frame , if already exist then i will show one pop_up Dialog to display "Already opened" or to show the frame in front of all opened frame.how i solve this ?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

Vijay,
Please UseAMeaningfulSubjectLine
You can change your subject line by clicking on the

How is the frame being opened? Some action such as button click? Or do you mean to say running the application twice opens two frames?
Please TellTheDetails


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
vijay Panner
Ranch Hand

Joined: Sep 29, 2010
Posts: 30
vijay Panner wrote:Hi,

I am developing one Desktop Application Using Swing. In my application, I designed Menu frame, whenever i click one menu_item respective page will load, suppose again i click same menu_item then one more same frame is opened.But i need only one frame , if already exist then i will show one pop_up Dialog to display "Already opened" or to show the frame in front of all opened frame.how i solve this ?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19674
    
  18

Keep a reference to the frame. Initially, if it's null, you create it and show it. Any future call it won't be null so you can just show it. Something like this:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How Donot open JFrame More then one time? please help