Results 1 to 7 of 7

Thread: prevent duplicate Jframes

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    419

    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!

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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

  3. #3
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    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.

  4. #4
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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

  5. #5
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: prevent duplicate Jframes

    Quote Originally Posted by ComputerJy View Post
    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.

  6. #6
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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

  7. #7
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: prevent duplicate Jframes

    Quote Originally Posted by ComputerJy View Post
    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
  •  



Click Here to Expand Forum to Full Width