Ejemplo n.º 1
0
  /** Center a component in the middle of the screen. */
  public static void centerComponent(java.awt.Component component) {
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    java.awt.Dimension size = component.getSize();

    screenSize.height = screenSize.height / 2;
    screenSize.width = screenSize.width / 2;

    size.height = size.height / 2;
    size.width = size.width / 2;

    component.setLocation(screenSize.width - size.width, screenSize.height - size.height);
  }
Ejemplo n.º 2
0
 /**
  * Returns the inside size as a Dimension.
  *
  * @return Inside size
  */
 public java.awt.Dimension getInsideSize() {
   java.awt.Dimension d = getSize();
   java.awt.Insets insets = getInsets();
   d.width -= insets.left + insets.right;
   d.height -= insets.top + insets.bottom;
   return d;
 }