Article View: borland.public.jbuilder.java.swing
Article #11513Re: How to Prevent multiple windows ??
From: Jason Burton
Date: Mon, 17 May 1999 00:00
Date: Mon, 17 May 1999 00:00
26 lines
1599 bytes
1599 bytes
> Could someone provide me with sample code to prevent users from opening > or instatiating a window that is already open or instantiated??. Thanks > a lot!! In one way or another, you are going to have to keep track of the windows that you have created. I use a class I call Application to keep track of the open forms. Instead of doing: MyFrame frame = new MyFrame(); I do: MyFrame frame = Application.createForm(MyFrame.class); The createForm method of the Application class checks to see if another other instances of MyFrame exist, and if so, it returns that instance. Otherwise, it creates a new MyFrame instance, adds it to an internal Vector, adds a listener to determine when the window is closed (so that it can remove it from the internal Vector), and returns the new instance. This can be handle similarly if you put this type of logic in your Frame constructor. All of your application's frames could then descend from your custom frame that handles this behavior. Hope this helps, Jason
Technical Details
Message-ID:
<7hpebe$9sr6@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<373E29CA.FB88EB03@kcbbs.gen.nz>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,3b14337d4d5eaa54 X-Google-Attributes: gid111d45,public From: "Jason Burton" <Jason.Burton@McLeodSoftware.com> Subject: Re: How to Prevent multiple windows ?? Date: 1999/05/17 Message-ID: <7hpebe$9sr6@forums.borland.com> X-Deja-AN: 479020163 References: <373E29CA.FB88EB03@kcbbs.gen.nz> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Newsgroups: borland.public.jbuilder.java.swing