🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
3 messages
3 total messages Started by Alex Terehoff Fri, 21 May 2004 14:11
Re-center JDialog on resize
#948
Author: 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
Re: Re-center JDialog on resize
#949
Author: Lori M Olson (TeamB)
Date: Fri, 21 May 2004 19:39
26 lines
1612 bytes
Alex Terehoff wrote:

> Can someone help me how I can re-center one of my JDialogs on its resize.

My personal favorite :

setLocationRelativeTo( null );

-- 

Regards,

Lori Olson (TeamB)

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
     http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
     http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
     http://www.visi.com/~gyles19/fom-serve/cache/1.html
Re: Re-center JDialog on resize
#993
Author: 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
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads