Article View: borland.public.jbuilder.java.swing
Article #11783Re: JFrame & setModal ?
From: Jason Burton
Date: Wed, 14 Apr 1999 00:00
Date: Wed, 14 Apr 1999 00:00
36 lines
1484 bytes
1484 bytes
Sohan Mendis wrote in message <7eru1c$9ut16@forums.borland.com>...
>Is it possible to make a JFrame modal ?
You must use a JDialog instead of a JFrame. I had the problem of needing to
show my GUI's modally or modeless a while back, and here's trick I used:
I do all of my design on the following (trimmed down for demo purposes)
JPanel subclass:
public class FramePanel
{
public void show()
{
JFrame frame = new JFrame();
frame.getContentPane().add(this);
frame.show();
}
public void showModal()
{
JDialog frame = new JDialog);
frame.getContentPane().add(this);
frame.setModal(true);
frame.show();
}
}
This gives me both the show() and showModal() for a given GUI, and you never
need to know that you aren't showing a frame. Keep in mind that you might
need to surface some of the JFrame properties in your JPanel class, though.
Hope this helps,
Jason
Technical Details
Message-ID:
<7f2uvq$gpf10@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7eru1c$9ut16@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,86c6367a3ca8b215 X-Google-Attributes: gid111d45,public From: "Jason Burton" <Jason.Burton@McLeodSoftware.com> Subject: Re: JFrame & setModal ? Date: 1999/04/14 Message-ID: <7f2uvq$gpf10@forums.borland.com> X-Deja-AN: 466439994 References: <7eru1c$9ut16@forums.borland.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.swing