How to place the application's original window?

R

Ramon F Herrera

When a jDialog is created, the calling class sets in advance
the place where the new windows should appear (see code below).
The original window, however, is sort of "parent-less", so how
can I specify the root window's location?

Thanks,

-Ramon F. Herrera

ps: the code below was automatically generated
by JBuilder's IDE.

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

//Help | About action performed
public void jMenuHelpAbout_actionPerformed(ActionEvent e) {
Frame1_AboutBox dlg = new Frame1_AboutBox(this);
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.setModal(true);
dlg.pack();
dlg.show();
}
 
N

nos

Ramon F Herrera said:
When a jDialog is created, the calling class sets in advance
the place where the new windows should appear (see code below).
The original window, however, is sort of "parent-less", so how
can I specify the root window's location?

For me, the name of the root window is NewDraw, and
this works for me.
Point loc = NewDraw.window.getLocationOnScreen();
 
A

Andrew Hobbs

Ramon F Herrera said:
When a jDialog is created, the calling class sets in advance
the place where the new windows should appear (see code below).
The original window, however, is sort of "parent-less", so how
can I specify the root window's location?

How about something like

Dimension dim = getToolkit().getScreenSize();
Rectangle abounds = getBounds();
this.setLocation((dim.width - abounds.width) / 2, (dim.height -
abounds.height) / 2);

This sets it in the middle of the screen. However it is trivial to use
something similar to set it wherever you want.

Cheers

Andrew


--
********************************************************
Andrew Hobbs PhD

MetaSense Pty Ltd - www.metasense.com.au
Australia

61 8 9246 2026
metasens AntiSpam @iinet dot net dot au


*********************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,241
Latest member
Lisa1997

Latest Threads

Top