aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFrame" Watch "JFrame" New topic
Author

JFrame

remi vandana
Greenhorn

Joined: Aug 24, 2001
Posts: 6
hi,
pl. help me in acheving foll...
i hv JMenu attached to JFrame.
i hv a JDialog boxes wch are invoked by clicking on JmenuItems.
the prob is tht, i hv a 17 inch monitor and i hv used setLocation() method to place thd dlg box on JFrame. Whenever the dialog box appears its at the location wch i hv set but if the same code is run on 14 inch or 15 inch or on any other dimennsion of monitor the location on tht monitor is unpredictable....
either the dlg box is shifted to some corner or it almost gets hidden...
how to set correct locaton of dlg so tht its appearance remins same on all kinds of monitors of any dim. also i want tht all the dlg boxes of any size shd appear exactly in middle of the JFrame.
i also used getDefaultToolkit method.
pl. reply soon....
Vinod Venugopal
Ranch Hand

Joined: Dec 06, 2000
Posts: 148
Well, actually speaking getToolkit should do, would like to c ur code, but anyway heres some sample code u can use...
// centers the dialog within the screen
public void centerScreen()
{
Dimension dim = getToolkit().getScreenSize();
Rectangle abounds = getBounds();
setLocation((dim.width - abounds.width) / 2,
(dim.height - abounds.height) / 2);
super.setVisible(true);
//requestFocus();
}

- Vinod<br />-------<br />SCJP2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFrame
 
Similar Threads
Swings + Event handeling
Swings
JOptionPane
Swings + Image
JTextField + Listener