• Post Reply Bookmark Topic Watch Topic
  • New Topic

let me know

 
narayana murthy pedapudi
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have MDI Application in that i am using JFrames.What i want is when a frame is opened then another instance of the same frame should not open.
is there any method or technique to implement this. when that frame is closed then u can open that frame.
Thanks and Regards
narayana
 
Idly Vada
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by narayana murthy pedapudi:
I have MDI Application in that i am using JFrames.What i want is when a frame is opened then another instance of the same frame should not open.
is there any method or technique to implement this. when that frame is closed then u can open that frame.


Use a static variable in the frame class to maintain number of active instances of the frame. If it is zero then only instantiate a new instance.
Whenever you close a frame subtract 1 from the static variable ( in the windowClosing() method of WindowListener).
This will solve your problem
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!