Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How Donot open JFrame More then one time? please help

 
vijay Panner
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
vijay Panner
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20510
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic