Class CenterComponent

java.lang.Object
org.gvsig.utils.centerComponent.CenterComponent

public class CenterComponent extends Object
Allows center a component (Ex. JInternalFrame, JFrame, etc.) respect its parent component Exceptions:
  • If the component is a JDialog -> better use:
    jDialog.setLocationRelativeTo(parentComponent);
  • If the component is a JFrame or a JWindow -> better use:
    jFrame.setSize(width, height);
    jFrame.setLocationRelativeTo(null);
    or
    jWindow.setSize(width, height);
    jWindow.setLocationRelativeTo(null);
Author:
Pablo Piqueras Bartolomé (p_queras@hotmail.com)
  • Constructor Details

    • CenterComponent

      public CenterComponent()
  • Method Details

    • centerComponent

      public static void centerComponent(Component component, Rectangle parentBounds)
      Centers a component (Ex. JInternalFrame, JFrame, etc.) according its size and the bounds of its parent
      Exceptions:
      • If the component is a JDialog -> better use:
        jDialog.setLocationRelativeTo(parentComponent);
      • If the component is a JFrame or a JWindow -> better use:
        jFrame.setSize(width, height);
        jFrame.setLocationRelativeTo(null);
        or
        jWindow.setSize(width, height);
        jWindow.setLocationRelativeTo(null);
      Parameters:
      component - The component to center
      parentBounds - Bounds of the parent of the component.