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?
Re: prevent duplicate Jframes
Use a Singleton class for that Gui
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.
Re: prevent duplicate Jframes
Quote:
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!
Re: prevent duplicate Jframes
Quote:
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.
Re: prevent duplicate Jframes
I like laziness so no need to read if you have the answer :D
Re: prevent duplicate Jframes
Quote:
Originally Posted by
ComputerJy
I like laziness so no need to read if you have the answer :D
I like your style. :afrog: