🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re-center JDialog on resize

#948
From: Alex Terehoff
Date: Fri, 21 May 2004 14:11
36 lines
1970 bytes
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: <40ae0df9$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,392ddb9a9f9096b2,start
X-Google-Attributes: gid111d45,public
From: "Alex Terehoff" <aterehoff@hotmail.com>
Newsgroups: borland.public.jbuilder.java.swing
Subject: Re-center JDialog on resize
Date: Fri, 21 May 2004 10:11:06 -0400
Lines: 38
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: 198.179.0.1
Message-ID: <40ae0df9$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1085148665 198.179.0.1 (21 May 2004 07:11:05 -0700)
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail