Class ComponentHelper

java.lang.Object
net.simplace.core.service.ComponentHelper

public final class ComponentHelper extends Object
Helper for GUI components.
Author:
Andreas Enders
  • Method Details

    • isAnchestor

      public static boolean isAnchestor(Component aComponent, Component aAnchestorComponent)
      Returns true if the first component is an anchestor of the second component.
      Parameters:
      aComponent -
      aAnchestorComponent -
      Returns:
      success
    • findFirstJTextArea

      public static JTextArea findFirstJTextArea(JComponent aComponent)
      Returns the first descendant component of type JTextArea.
      Parameters:
      aComponent -
      Returns:
      the first descendant component of type JTextArea
    • getColumn

      public static TableColumn getColumn(JTable aTable, int aModelIndex)
      Returns the column at the given model-column. This will ignore the actual position of the column.
      Parameters:
      aTable -
      aModelIndex -
      Returns:
      the column at the given model-column
    • fitColumnWidth

      public static void fitColumnWidth(JTable aTable, int aMaxWidth, boolean aResizable)
      Fits all columns in the table to perfect size.
      Parameters:
      aTable -
      aMaxWidth -
      aResizable -
    • fitColumnWidth

      public static int fitColumnWidth(JTable aTable, int aColumnIndex, int aMaxWidth, boolean aResizable)
      Fits the column to perfect size.
      Parameters:
      aTable -
      aColumnIndex -
      aMaxWidth -
      aResizable -
      Returns:
      column width
    • fitColumnWidth

      public static int fitColumnWidth(JTable aTable, int aColumnIndex, int aMinWidth, int aMaxWidth, boolean aResizable)
      Fits the column to perfect size.
      Parameters:
      aTable -
      aColumnIndex -
      aMinWidth -
      aMaxWidth -
      aResizable -
      Returns:
      column width
    • transformColor

      public static Color transformColor(Color aColor, int aAbsoluteChangeValue)
      Returns a brighter/darker color based on absolute RGB transformation.
      Parameters:
      aColor -
      aAbsoluteChangeValue -
      Returns:
      a brighter/darker color based on absolute RGB transformation
    • transformColor

      public static Color transformColor(Color aColor, double aRelativeChangeValue)
      Returns a brighter/darker color based on relative RGB transformation. value < 1.0 -> darker value = 1.0 -> same value > 1.0 -> brighter
      Parameters:
      aColor -
      aRelativeChangeValue -
      Returns:
      a brighter/darker color based on relative RGB transformation
    • isToolkitTrueColor

      public static boolean isToolkitTrueColor(Component aComponent)
      Checks if color depth is at least 24 bit.
      Parameters:
      aComponent -
      Returns:
      true, if color depth is at least 24 bit
    • setDefaultWindowBounds

      public static void setDefaultWindowBounds(Window aWindow)
      Sets the default size and location of the given window.
      Parameters:
      aWindow -
    • getComponentByBounds

      public static Component getComponentByBounds(Container aParent, int aX, int aY)
      Returns the component given by the bounds.
      Parameters:
      aParent -
      aX -
      aY -
      Returns:
      the component given by the bounds
    • centerWindow

      public static void centerWindow(Window aWindow)
      Centers the given window relative to its parent. If no parent is available, the window is centered on the screen.
      Parameters:
      aWindow -
    • combineIcons

      public static ImageIcon combineIcons(ImageIcon aIcon, int aIconX, int aIconY, ImageIcon aCoIcon, int aCoIconX, int aCoIconY)
      Combines the given icons.
      Parameters:
      aIcon -
      aIconX -
      aIconY -
      aCoIcon -
      aCoIconX -
      aCoIconY -
      Returns:
      combined ImageIcon
    • combineIcons

      public static ImageIcon combineIcons(ImageIcon aIcon, int aIconX, int aIconY, ImageIcon aCoIcon, int aCoIconX, int aCoIconY, boolean aFadeIcon)
      Combines the given icons.
      Parameters:
      aIcon -
      aIconX -
      aIconY -
      aCoIcon -
      aCoIconX -
      aCoIconY -
      aFadeIcon -
      Returns:
      combined ImageIcon
    • combineColors

      public static Color combineColors(Color aColor1, Color aColor2)
      Combines two different colors.
      Parameters:
      aColor1 -
      aColor2 -
      Returns:
      combined Color
    • createColor

      public static Color createColor(String aColorString)
      Creates an RGB-Color from the given CSV-String e.g. "127,0,0"
      Parameters:
      aColorString -
      Returns:
      an RGB-Color
    • setHeight

      public static void setHeight(JComponent aComponent, int aHeight)
      Sets the preferred height to a component.
      Parameters:
      aComponent -
      aHeight -
    • fadeIconColors

      public static ImageIcon fadeIconColors(ImageIcon aImageIcon)
      Brightens the given image
      Parameters:
      aImageIcon -
      Returns:
      brightened ImageIcon