Article View: borland.public.jbuilder.java.swing
Article #539Re: How to refocus an open (modoal==false) jDialog
From: Magnus
Date: Tue, 14 Jun 2005 19:41
Date: Tue, 14 Jun 2005 19:41
50 lines
2642 bytes
2642 bytes
Returning to my old problem.
For now I have solved this with a flag that is set when the window is
opened and reset upon close. I then test on its flag before open a "new"
window every time.
To be able to reset the flag I added :
setupWindow.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
setMyFlag(false);
}
});
This works great if the "x" in the frame is used to close the window,
but, I have added a "close" button in my setupWindow and the actioncode
there is: this.dispose();
Now that doesn't bring me to my listener above so I must make my flag
static and I call setMyFlag from the close-button.
Can I use something else than "this.dispose()" to get the same action as
for the "x" in upper frame menu?
Thanks for any help and hints.
Magnus wrote:
> Hello,
>
> I have a menu entry that open a dialog.
> The user can go back to original screen and open a new dialog from the
> same menu entry.
> I would like to re-focus on the first one but can find a way to do this.
>
> public void jMenuItem1_actionPerformed(ActionEvent e) {
>
> // Here I want to refocus if opened before ...
>
> Calculator dlg = new Calculator(this, "Just Test of Dialog", false);
> Dimension dlgSize = dlg.getPreferredSize();
> Dimension frmSize = getSize();
> Point loc = getLocation();
> dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
> (frmSize.height - dlgSize.height) / 2 + loc.y);
> dlg.pack();
> dlg.show();
> }
>
> Thanks in advance
Technical Details
Message-ID:
<42af32c8@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<42669161@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,96415b146a3c2aed X-Google-Attributes: gid111d45,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Tue, 14 Jun 2005 15:41:03 -0400 From: Magnus <magnus_bjorkman@iwon.com> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) X-Accept-Language: en-us, en, sv MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing Subject: Re: How to refocus an open (modoal==false) jDialog References: <42669161@newsgroups.borland.com> In-Reply-To: <42669161@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 71.0.99.227 Message-ID: <42af32c8@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1118778056 71.0.99.227 (14 Jun 2005 12:40:56 -0700) Lines: 50 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail