Class ComponentUtil

  • All Implemented Interfaces:

    
    public final class ComponentUtil
    
                        

    This class is a Util for awt Component and could be used to place them in center of another.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static void centerComponentInWindow(Component component, int percentOfScreen) Use this static method if you want to center and set its position compared to the size of the current users screen size.
      static void centerComponentInWindow(Component component) Use this static method if you want to center a component in Window.
      static void centerComponentInComponent(Component parent, Component toBeCentered) Use this static method if you want to center a component over another component.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • centerComponentInWindow

         static void centerComponentInWindow(Component component, int percentOfScreen)

        Use this static method if you want to center and set its position compared to the size of the current users screen size. Valid percent is between +-(0-100) minus is treated as plus, bigger than 100 is always set to 100.

        Parameters:
        component - the component you want to center and set size on
        percentOfScreen - the percent of the current screen size you want the component to be
      • centerComponentInWindow

         static void centerComponentInWindow(Component component)

        Use this static method if you want to center a component in Window.

        Parameters:
        component - the component you want to center in window
      • centerComponentInComponent

         static void centerComponentInComponent(Component parent, Component toBeCentered)

        Use this static method if you want to center a component over another component.

        Parameters:
        parent - the component you want to use to place it on
        toBeCentered - the component you want to center