🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Re-center JDialog on resize

#993
From: Daniel
Date: Sun, 15 Aug 2004 04:56
55 lines
3018 bytes
hi,

rather than overriding that method, try to add a window listener to the
dialog. if this does not work, it means that the listener is not retrieving
the appropriate information about the window size and location - might
retrieve the old values.

In this case, try to move the process of retrieving the coordinates and
resize the window somewhere else, by placing them in a
SwingUtils.invokeLater(Runnable stuff) call

Regards,
Daniel

"Alex Terehoff" <aterehoff@hotmail.com> wrote in message
news:40ae0df9$1@newsgroups.borland.com...
> Can someone help me how I can re-center one of my JDialogs on its resize.
> I tried the following but it does not work
> void this_componentResized(ComponentEvent e) {
>     try{
>       Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
>       Dimension frameSize = this.getSize();
>       if (frameSize.height > screenSize.height) {
>         frameSize.height = screenSize.height;
>       }
>       if (frameSize.width > screenSize.width) {
>         frameSize.width = screenSize.width;
>       }
>       this.setLocation( (screenSize.width - frameSize.width) / 2,
>                         (screenSize.height - frameSize.height) / 2);
>       this.validate();
>
>     }
>     catch(Exception ex){
>       JOptionPane.showMessageDialog(null,"An error has occured in the
> application. \n"+
>                                         "Error:
> ex.getMessage ),"Error",JOptionPane.WARNING_MESSAGE);
>     }
>
>   }
>
> I alos wondering if I can open a JDialog miximized.
>
> I tried a few things but nothing seemed work for me. It is not centered
and
> covere by the Windows XP Status Bar. Not pretty...
>
> Alex
>
> Alex G. Terehoff
> Booz | Allen | Hamilton
> tel: (301) 427-1758
>
>
Technical Details
Message-ID: <EPSdnS-349NgcYPcRVn-uw@giganews.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
References: <40ae0df9$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,392ddb9a9f9096b2
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 14 Aug 2004 23:56:29 -0500
From: "Daniel" <dgabrov1@yahoo.com>
Newsgroups: borland.public.jbuilder.java.swing
References: <40ae0df9$1@newsgroups.borland.com>
Subject: Re: Re-center JDialog on resize
Date: Sun, 15 Aug 2004 00:56:23 -0400
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <EPSdnS-349NgcYPcRVn-uw@giganews.com>
Lines: 57
X-Trace: sv3-qgliscFrz2k5Pv0T6omIgsKVmqGrQaUk5n4YnJllQCrQfaLNBTK/qDAwHmWXjPIEp7lGGMqqBoefuBN!RYV67nEY3pkAAAbbKAcUcoIdmsmkqWUCWUJEz+gR9KutE7byqARvMNHBP1jDFQ==
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.13