🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #11364

Solved: JDialog Problem

#11364
From: Matthias Bandemer
Date: Thu, 03 Jun 1999 00:00
50 lines
2257 bytes
Hi,

I have searched DejaNews and have found the solution. Here is the code :

JFrame topFrame = (JFrame) this.getTopLevelAncestor();
JDialog topDialog = new JDialog(topFrame, "title", true);
topDialog.show();

Now it works fine, but I wonder what the first line means. Is this a
kind of a casting-methode? I have never seen this before. Any comments ?

Thanks

Matthias
Matthias Bandemer wrote:
> 
> Hi,
> 
> using the getTopLevelAncestor()- Method I get a "constructor not found"
> -message, because getTopLevelAncestor() returns a container, not a
> frame.
> 
> here ist the constructor:     JDialog modDia = new
> JDialog(this.getTopLevelAncestor(),"Modify Data", true);
> 
> Is it posible to cast this into a frame or ist there another solution?
> 
> Matt Krevs wrote:
> >
> > call getTopLevelAncestor() to get a handle to the frame that you nested
> > panels are on.
> >
> > Matthias Bandemer <matthias.bandemer@gmx.de> wrote in message
> > news:375585BB.1F9323B5@gmx.de...
> > > Hi,
> > >
> > > I have a problem with creating a JDialog. I want to create a modal
> > > dialog with titel "Modifying Data". So I use this constructor
> > >
> > > JDialog(Frame parentFrame, String title, boolean modal)
> > >
> > > but the parent component of this dialog is a panel. This panel is a
> > > child-component of another panel, which is the contentpane of the
> > > top-level-frame. Thats why I get an "incompatible types found" message:
> > > "found component, frame required". How con I access the top-level-frame
> > > from the JDialog-constructor?
> > >
> > > Thanks for help,
> > >
> > > Matthias
Technical Details
Message-ID: <375640B1.40CDB7F4@gmx.de>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <375585BB.1F9323B5@gmx.de> <7j4fkb$jmc9@forums.borland.com> <37563987.834091D@gmx.de>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,c40ee21b1dbc2637
X-Google-Attributes: gid111d45,public
From: Matthias Bandemer <matthias.bandemer@gmx.de>
Subject: Solved: JDialog Problem
Date: 1999/06/03
Message-ID: <375640B1.40CDB7F4@gmx.de>
X-Deja-AN: 485193578
Content-Transfer-Encoding: 7bit
References: <375585BB.1F9323B5@gmx.de> <7j4fkb$jmc9@forums.borland.com> <37563987.834091D@gmx.de>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing