Article View: borland.public.jbuilder.java.swing
Article #1371Re: Dialog box association
From: Matthew Sweet
Date: Tue, 16 Dec 2003 18:18
Date: Tue, 16 Dec 2003 18:18
54 lines
3362 bytes
3362 bytes
I think I figured it out. I had "ColorChooser colorChooserDlg = new
ColorChooser( (Frame) SwingUtilities.windowForComponent(this));" in the
initialization section of my containor class. I moved it to the mouse
adapter class. Dont' really understand why unless I needed to call
colorChooserDlg.show() somewhere else.
// "this" is a JPanel. The code is basically from the About box code
ColorChooser colorChooserDlg = new ColorChooser( (Frame)
SwingUtilities.windowForComponent(this));
Dimension dlgSize = colorChooserDlg.getPreferredSize();
Dimension frmSize = getSize();
Point loc = getLocation();
colorChooserDlg.setLocation( (frmSize.width - dlgSize.width) / 2 +
loc.x,
(frmSize.height - dlgSize.height) / 2 +
loc.y);
colorChooserDlg.setModal(true);
colorChooserDlg.pack();
colorChooserDlg.show();
"Matthew Sweet" <matthew.sweet@sed.redstone.army.mil> wrote in message
news:3fdf4a1a$1@newsgroups.borland.com...
> I get the same result with what you suggested. Before I had
> (Frame)SwingUtilities.getAncestorOfClass(Frame.class, this) I guess they
are
> doing the same thing. Ultimately my problem is that I lose my dialog box
in
> the background when I click on another window and back onto my application
> window. Is this a problem with an incorrect association or do I need to
call
> some other function to make it come back?
>
>
> "Gillmer J. Derge (TeamB)" <spam@gillmerderge.com> wrote in message
> news:3fdf40cd$1@newsgroups.borland.com...
> > "Matthew Sweet" <matthew.sweet@sed.redstone.army.mil> wrote in message
> > news:3fdf2537$1@newsgroups.borland.com...
> > > I can't get to the Frame component from that
> > > last JPanel class to pass it into the JDialog class I created.
> >
> > (JFrame)SwingUtilities.windowForComponent(panel);
> >
> > Since windowForComponent returns a Window, you might want to verify that
> > it's an instance of JFrame before casting it, but this shows the basic
> > idea.
> >
> > --
> > Gillmer J. Derge (TeamB)
> >
>
>
Technical Details
Message-ID:
<3fdf4cd0$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!in.100proofnews.com!in.100proofnews.com!news02.tsnz.net!newsfeed01.tsnz.net!news.xtra.co.nz!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3fde2463@newsgroups.borland.com> <3fde265c$1@newsgroups.borland.com> <3fdf2537$1@newsgroups.borland.com> <3fdf40cd$1@newsgroups.borland.com> <3fdf4a1a$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,55c92298dba121d1 X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2003-12-16 10:40:54 PST Reply-To: "Matthew Sweet" <matthew.sweet@sed.redstone.army.mil> From: "Matthew Sweet" <matthew.sweet@sed.redstone.army.mil> Newsgroups: borland.public.jbuilder.java.swing References: <3fde2463@newsgroups.borland.com> <3fde265c$1@newsgroups.borland.com> <3fdf2537$1@newsgroups.borland.com> <3fdf40cd$1@newsgroups.borland.com> <3fdf4a1a$1@newsgroups.borland.com> Subject: Re: Dialog box association Date: Tue, 16 Dec 2003 12:18:06 -0600 Lines: 56 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 136.205.73.67 Message-ID: <3fdf4cd0$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1071598800 136.205.73.67 (16 Dec 2003 10:20:00 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!in.100proofnews.com!in.100proofnews.com!news02.tsnz.net!newsfeed01.tsnz.net!news.xtra.co.nz!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail