Use SwingUtil to center frames within the screen bounds.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@201 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
shaper
2001-07-21 02:04:37 +00:00
parent fa41492090
commit db024caaf5
2 changed files with 8 additions and 12 deletions
@@ -1,5 +1,5 @@
// //
// $Id: Chooser.java,v 1.3 2001/07/13 00:10:48 mdb Exp $ // $Id: Chooser.java,v 1.4 2001/07/21 02:04:37 shaper Exp $
package robodj.chooser; package robodj.chooser;
@@ -9,6 +9,7 @@ import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Properties; import java.util.Properties;
import com.samskivert.swing.util.SwingUtil;
import com.samskivert.util.PropertiesUtil; import com.samskivert.util.PropertiesUtil;
import robodj.Log; import robodj.Log;
@@ -76,11 +77,8 @@ public class Chooser
// create our primary user interface frame, center the frame in // create our primary user interface frame, center the frame in
// the screen and show it // the screen and show it
ChooserFrame frame = new ChooserFrame(); ChooserFrame frame = new ChooserFrame();
Toolkit tk = frame.getToolkit(); frame.setSize(550, 500);
Dimension ss = tk.getScreenSize(); SwingUtil.centerFrame(frame);
int width = 550, height = 500;
frame.setBounds((ss.width-width)/2, (ss.height-height)/2,
width, height);
frame.setVisible(true); frame.setVisible(true);
} }
} }
@@ -1,5 +1,5 @@
// //
// $Id: Importer.java,v 1.4 2001/06/05 17:40:18 mdb Exp $ // $Id: Importer.java,v 1.5 2001/07/21 02:04:37 shaper Exp $
package robodj.importer; package robodj.importer;
@@ -8,6 +8,7 @@ import java.awt.Toolkit;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Properties; import java.util.Properties;
import com.samskivert.swing.util.SwingUtil;
import com.samskivert.util.Log; import com.samskivert.util.Log;
import com.samskivert.util.PropertiesUtil; import com.samskivert.util.PropertiesUtil;
@@ -59,11 +60,8 @@ public class Importer
frame.setPanel(panel); frame.setPanel(panel);
// center the frame in the screen and show it // center the frame in the screen and show it
Toolkit tk = frame.getToolkit(); frame.setSize(640, 480);
Dimension ss = tk.getScreenSize(); SwingUtil.centerFrame(frame);
int width = 640, height = 480;
frame.setBounds((ss.width-width)/2, (ss.height-height)/2,
width, height);
frame.setVisible(true); frame.setVisible(true);
} }
} }