|
-
Dec 22nd, 2009, 06:21 PM
#1
Thread Starter
Hyperactive Member
prevent duplicate Jframes
I have a couple of classes, one is my mainGUI which has a JMenu in it, if a certain JMenuItem is select it will create a new GUI (this other GUI is another window thats totally different). The new GUI opens up as i want but i can continue to create a new instances of this GUI.
So the basic question is... How do i ensure my program only allows one instance of this GUI?
If a post has been usefull then Rate it! 
-
Dec 22nd, 2009, 07:17 PM
#2
Re: prevent duplicate Jframes
Use a Singleton class for that Gui
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Dec 22nd, 2009, 09:51 PM
#3
Re: prevent duplicate Jframes
Just elaborating a little but in what Jy suggests; You should definitely do some research on design patterns. It was something that was never even mentioned while I was in college but can help put you in the proper mindset when problems like these occur.
For a very basic overview of the different design patterns, you can look here.
-
Dec 22nd, 2009, 10:27 PM
#4
Re: prevent duplicate Jframes
It was something that was never even mentioned while I was in college
Back then Software engineering was someone's job title not a college class or major. I agree, design patterns are important for people to know but I can't see where does it fit in this issue!
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Dec 23rd, 2009, 07:05 AM
#5
Re: prevent duplicate Jframes
 Originally Posted by ComputerJy
I agree, design patterns are important for people to know but I can't see where does it fit in this issue!
Maybe I misunderstood this statement, but singleton is a design pattern. So I must go with my first instinct and ask what you mean in that sentence.
-
Dec 23rd, 2009, 07:20 AM
#6
Re: prevent duplicate Jframes
I like laziness so no need to read if you have the answer
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Dec 23rd, 2009, 08:34 AM
#7
Re: prevent duplicate Jframes
 Originally Posted by ComputerJy
I like laziness so no need to read if you have the answer 
I like your style.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|