com.alee.utils
Class SwingUtils

java.lang.Object
  extended by com.alee.utils.SwingUtils

public final class SwingUtils
extends java.lang.Object

This class provides a set of utilities to work with Swing components, their settings and events.

Author:
Mikle Garin

Field Summary
static java.lang.String HANDLES_ENABLE_STATE
          Client property key that identifies that component can handle enabled state changes.
 
Constructor Summary
SwingUtils()
           
 
Method Summary
static void applyOrientation(java.awt.Component component)
          Applies component orientation to specified component.
static void applyOrientation(java.awt.Component component, boolean forced)
          Applies component orientation to specified component if needed or if forced.
static
<C extends java.awt.Component>
C
changeFontSize(C component, int change)
          Changes font size of the specified component.
static java.util.List<java.awt.Container> collectAllContainers(java.awt.Container container)
          Returns list of all sub-containers for this container.
static java.util.List<java.awt.Container> collectAllContainers(java.awt.Container container, java.util.List<java.awt.Container> containers)
          Returns list of all sub-containers for this container.
static java.awt.Rectangle contentSize(java.awt.Component component)
          Returns component content size limited by component border.
static java.awt.Color copy(java.awt.Color color)
          Returns color copy.
static java.awt.Dimension copy(java.awt.Dimension dimension)
          Returns dimension copy.
static java.awt.Insets copy(java.awt.Insets insets)
          Returns insets copy.
static java.awt.Point copy(java.awt.Point point)
          Returns point copy.
static java.awt.Rectangle copy(java.awt.Rectangle rectangle)
          Returns rectangle copy.
static void copyOrientation(java.awt.Component from, java.awt.Component to)
          Copies component orientation from one component to another.
static java.awt.image.BufferedImage createComponentSnapshot(java.awt.Component content)
          Returns component snapshot image.
static java.awt.image.BufferedImage createComponentSnapshot(java.awt.Component content, int width, int height)
          Returns component snapshot image of specified size.
static java.awt.Font[] createFonts(java.lang.String[] fontNames)
          Returns an array of fonts created using specified array of font names.
static void delayInvokeLater(long delay, java.lang.Runnable runnable)
          Will perform an "invokeLater" call when the specified delay time passes.
static void destroyContainer(java.awt.Container container)
          Destroys container by destroying its childs structure and removing all listeners.
static java.util.List<java.awt.Component> disableRecursively(java.awt.Component component, boolean startFromChilds, boolean excludePanels, java.awt.Component... excluded)
          Disables component and all of its children recursively.
static java.util.List<java.awt.Component> disableRecursively(java.awt.Component component, boolean startFromChilds, boolean excludePanels, java.util.List<java.awt.Component> excluded)
          Disables component and all of its children recursively.
static void drawString(java.awt.Graphics g, java.lang.String text, int x, int y)
          Paints string.
static void drawStringUnderlineCharAt(java.awt.Graphics g, java.lang.String text, int underlinedIndex, int x, int y)
          Paints string with underlined character at the specified index.
static void enable(java.util.List<java.awt.Component> disabled)
          Enables specified components.
static void equalizeComponentsHeights(java.awt.Component... components)
          Makes all specified component heights equal.
static void equalizeComponentsSize(java.awt.Component... components)
          Makes all specified component sizes equal.
static void equalizeComponentsWidths(java.awt.Component... components)
          Makes all specified component widths equal.
static java.util.List<java.awt.Component> findComponentsWithText(java.lang.String text, java.awt.Component component)
          Returns list of all components that visually contains the specified text.
static java.util.List<java.awt.Component> findComponentsWithText(java.lang.String text, java.awt.Component component, java.util.List<java.awt.Component> components)
          Returns list of all components that visually contains the specified text.
static java.awt.Component findFocusableComponent(java.awt.Container container)
          Returns first focusable component found in the container.
static java.awt.Window getActiveWindow()
          Returns active application window.
static java.awt.Rectangle getBoundsInWindow(java.awt.Component component)
          Returns component bounds inside its window.
static java.awt.Rectangle getBoundsOnScreen(java.awt.Component component)
          Returns component bounds on screen.
static java.util.Map<java.awt.Component,java.awt.Dimension> getChildPreferredSizes(java.awt.Container container)
          Returns map of container child components preferred sizes.
static java.awt.Container getContentPane(java.awt.Component component)
          Returns content pane for the specified component or null if it doesn't exist.
static java.awt.Font getDefaultLabelFont()
          Returns default label font.
static
<T> T
getFirstParent(java.awt.Component component, java.lang.Class<T> parentClass)
          Returns first parent which is instance of specified class type or null if none found.
static java.awt.FontMetrics getFontMetrics(javax.swing.JComponent c, java.awt.Graphics g)
          Returns the FontMetrics for the current Font of the passed in Graphics.
static java.awt.FontMetrics getFontMetrics(javax.swing.JComponent c, java.awt.Graphics g, java.awt.Font font)
          Returns the FontMetrics for the specified Font.
static java.lang.String getFontName(java.awt.Component component)
          Returns component font name.
static java.lang.String[] getFontNames()
          Returns system font names array.
static java.awt.Font[] getFonts()
          Returns system fonts array.
static int getFontSize(java.awt.Component component)
          Returns font size of the specified component.
static java.awt.Component getGlassPane(java.awt.Component component)
          Returns glass pane for the specified component or null if it doesn't exist.
static boolean getHonorUserBorders(javax.swing.JComponent component)
          Returns whether UI delegate should honor a user-specified border on this component or not.
static HotkeyData getHotkeyData(javax.swing.KeyStroke keyStroke)
          Returns hotkey data extracted from the specified key stroke.
static javax.swing.JLayeredPane getLayeredPane(java.awt.Component component)
          Returns layered pane for the specified component or null if it doesn't exist.
static int getLeftSideBearing(javax.swing.JComponent c, java.awt.FontMetrics fm, char firstChar)
          Returns the left side bearing of the specified character.
static int getLeftSideBearing(javax.swing.JComponent c, java.awt.FontMetrics fm, java.lang.String string)
          Returns the left side bearing of the first character of string.
static java.awt.Point getMousePoint(java.awt.Component component)
          Returns mouse point relative to specified component.
static java.awt.Rectangle getRelativeBounds(java.awt.Component component, java.awt.Component relativeTo)
          Returns component bounds relative to another component.
static java.awt.Point getRelativeLocation(java.awt.Component component, java.awt.Component relativeTo)
          Returns component location relative to another component.
static int getRightSideBearing(javax.swing.JComponent c, java.awt.FontMetrics fm, char lastChar)
          Returns the right side bearing of the specified character.
static int getRightSideBearing(javax.swing.JComponent c, java.awt.FontMetrics fm, java.lang.String string)
          Returns the right side bearing of the last character of string.
static javax.swing.JRootPane getRootPane(java.awt.Component component)
          Returns root pane for the specified component or null if it doesn't exist.
static javax.swing.JScrollPane getScrollPane(java.awt.Component component)
          Returns scroll pane for specified component if exists, null otherwise.
static int getSystemShortcutModifier()
          Returns system shortcut modifier.
static java.awt.Component getTopComponentAt(java.awt.Component component, int x, int y)
          Returns top component inside the specified container component at the specified point.
static java.awt.Window getWindowAncestor(java.awt.Component component)
          Returns window ancestor for specified component or null if it doesn't exist.
static javax.swing.ButtonGroup groupButtons(javax.swing.AbstractButton... buttons)
          Groups specified buttons and returns created button group.
static void groupButtons(javax.swing.ButtonGroup buttonGroup, javax.swing.AbstractButton... buttons)
          Groups buttons in the specified button group.
static javax.swing.ButtonGroup groupButtons(java.awt.Container container)
          Groups all buttons inside this container and returns created button group.
static javax.swing.ButtonGroup groupButtons(java.awt.Container container, boolean recursive)
          Groups all buttons inside this container and all subcontainers if requested and returns created button group.
static void groupButtons(java.awt.Container container, boolean recursive, javax.swing.ButtonGroup buttonGroup)
          Groups all buttons inside this container and all subcontainers if requested and returns created button group.
static boolean hasFocusableComponent(java.awt.Container container)
          Returns whether atleast one of child components within the specified container is focusable or not.
static boolean hasFocusOwner(java.awt.Component component)
          Returns whether component or any of its children has focus or not.
static java.lang.String hotkeyToString(boolean isCtrl, boolean isAlt, boolean isShift, java.lang.Integer keyCode)
          Returns readable form for specified hotkey.
static java.lang.String hotkeyToString(HotkeyData hotkeyData)
          Returns readable form of specified hotkey data.
static java.lang.String hotkeyToString(java.awt.event.KeyEvent keyEvent)
          Returns readable form of hotkey triggered by specified key event.
static java.lang.String hotkeyToString(javax.swing.KeyStroke keyStroke)
          Returns readable form of specified key stroke.
static void invokeAndWait(java.lang.Runnable runnable)
          Will invoke the specified action in EDT in case it is called from non-EDT thread.
static void invokeAndWaitSafely(java.lang.Runnable runnable)
          Will invoke the specified action in EDT in case it is called from non-EDT thread.
static void invokeLater(HotkeyRunnable runnable, java.awt.event.KeyEvent e)
          Will invoke the specified action later in EDT in case it is called from non-EDT thread.
static void invokeLater(java.lang.Runnable runnable)
          Will invoke the specified action later in EDT in case it is called from non-EDT thread.
static boolean isAlt(java.awt.event.InputEvent event)
          Returns whether ALT modifier is triggered by the specified event or not.
static boolean isAlt(int modifiers)
          Returns whether ALT modifier is triggered by the specified modifiers or not.
static boolean isBoldFont(java.awt.Component component)
          Returns whether component font is bold or not.
static boolean isCtrl(java.awt.event.InputEvent event)
          Returns whether CTRL modifier is triggered by the specified event or not.
static boolean isCtrl(int modifiers)
          Returns whether CTRL modifier is triggered by the specified modifiers or not.
static boolean isEqualOrChild(java.awt.Component component1, java.awt.Component component2)
          Returns whether the first component or any of its children are equal to second component or not.
static boolean isHandlesEnableState(java.awt.Component component)
          Returns whether HANDLES_ENABLE_STATE mark is set in this component to true or not.
static boolean isHeavyWeightWindow(java.awt.Window window)
          Returns whether specified window is a HeavyWeightWindow or not.
static boolean isItalicFont(java.awt.Component component)
          Returns whether component font is italic or not.
static boolean isLafDecorated(java.awt.Component component)
          Returns whether window in which specified component located is decorated by L&F or not.
static boolean isLeftMouseButton(java.awt.event.MouseEvent e)
          Returns whether event involves left mouse button or not.
static boolean isMiddleMouseButton(java.awt.event.MouseEvent e)
          Returns whether event involves middle mouse button or not.
static boolean isPlainFont(java.awt.Component component)
          Returns whether component font is plain or not.
static boolean isPopupTrigger(java.awt.event.MouseEvent e)
          Returns whether the specifid mouse events triggers popup menu or not.
static boolean isPreserveBorders(javax.swing.JComponent component)
          Returns whether UI delegate should preserve current border on this component or not.
static boolean isRightMouseButton(java.awt.event.MouseEvent e)
          Returns whether event involves right mouse button or not.
static boolean isSameAncestor(java.awt.Component component1, java.awt.Component component2)
          Returns whether specified components have the same ancestor or not.
static boolean isShift(java.awt.event.InputEvent event)
          Returns whether SHIFT modifier is triggered by the specified event or not.
static boolean isShift(int modifiers)
          Returns whether SHIFT modifier is triggered by the specified modifiers or not.
static boolean isShortcut(java.awt.event.InputEvent event)
          Returns whether specified event contains shortcut modifier or not.
static java.awt.Dimension max(java.awt.Component... components)
          Returns maximum dimension combined from specified components dimensions.
static java.awt.Dimension max(java.awt.Component component1, java.awt.Component component2)
          Returns maximum dimension combined from specified components dimensions.
static java.awt.Dimension max(java.awt.Dimension dimension1, java.awt.Dimension dimension2)
          Returns maximum dimension combined from specified ones.
static java.awt.Insets max(java.awt.Insets insets1, java.awt.Insets insets2)
          Returns maximum insets combined from the specified ones.
static int maxHeight(java.awt.Component... components)
          Returns maximum component height.
static int maxWidth(java.awt.Component... components)
          Returns maximum component width.
static java.awt.Dimension min(java.awt.Component component1, java.awt.Component component2)
          Returns minimum dimension combined from specified components dimensions.
static java.awt.Dimension min(java.awt.Dimension dimension1, java.awt.Dimension dimension2)
          Returns minimum dimension combined from specified ones.
static java.awt.Insets min(java.awt.Insets insets1, java.awt.Insets insets2)
          Returns minimum insets combined from the specified ones.
static void packColumnWidth(javax.swing.JTable table, int col)
          Packs table column at the specified index to its preferred width.
static void packColumnWidth(javax.swing.JTable table, int col, int margin)
          Packs table column at the specified index to its preferred width.
static void packColumnWidths(javax.swing.JTable table)
          Packs all table columns to their preferred width.
static void packColumnWidths(javax.swing.JTable table, int margin)
          Packs all table columns to their preferred width.
static void packRowHeights(javax.swing.JTable table)
          Packs all table rows to their preferred height.
static void removeHandlesEnableStateMark(javax.swing.JComponent component)
          Removes HANDLES_ENABLE_STATE mark from component client properties.
static void restoreTextAntialias(java.awt.Graphics2D g2d, java.util.Map hints)
          Restores text antialiasing hints into specified graphics context
static void restoreTextAntialias(java.awt.Graphics g, java.util.Map hints)
          Restores text antialiasing hints into specified graphics context
static void scrollSmoothly(javax.swing.JScrollPane scrollPane, int xValue, int yValue)
          Scrolls scroll pane visible area smoothly to destination values.
static void setAccelerator(javax.swing.JMenuItem menuItem, HotkeyData hotkey)
          Sets menu item accelerator using the specified hotkey data.
static void setBackgroundRecursively(java.awt.Component component, java.awt.Color bg)
          Sets background color of component and all of its children.
static void setBackgroundRecursively(java.awt.Component component, java.awt.Color bg, boolean childsOnly)
          Sets background color of component and all of its children.
static
<C extends java.awt.Component>
C
setBoldFont(C component)
          Changes font to bold for the specified component.
static
<C extends java.awt.Component>
C
setBoldFont(C component, boolean apply)
          Changes font to bold for the specified component.
static
<C extends javax.swing.JComponent>
C
setBorder(C component, javax.swing.border.Border border)
          Sets border for the specified component.
static
<C extends javax.swing.JComponent>
C
setBorder(C component, int border)
          Sets an empty border for the specified component.
static
<C extends javax.swing.JComponent>
C
setBorder(C component, int top, int left, int bottom, int right)
          Sets an empty border for the specified component.
static void setDoubleBufferedRecursively(java.awt.Component component, boolean doubleBuffered)
          Sets double buffered state of component and all of its children.
static void setDoubleBufferedRecursively(java.awt.Component component, boolean doubleBuffered, boolean childsOnly)
          Sets double buffered state of component and all of its children.
static void setEnabledRecursively(java.awt.Component component, boolean enabled)
          Sets enabled state of component and all of its children.
static void setEnabledRecursively(java.awt.Component component, boolean enabled, boolean startFromChilds)
          Sets enabled state of component and all of its children.
static void setFocusableRecursively(javax.swing.JComponent component, boolean focusable)
          Sets focusable state of component and all of its children.
static void setFocusableRecursively(javax.swing.JComponent component, boolean focusable, boolean childsOnly)
          Sets focusable state of component and all of its children.
static
<C extends java.awt.Component>
C
setFontName(C component, java.lang.String fontName)
          Sets component font name.
static void setFontRecursively(javax.swing.JComponent component, java.awt.Font font)
          Sets font of component and all of its children.
static void setFontRecursively(javax.swing.JComponent component, java.awt.Font font, boolean childsOnly)
          Sets font of component and all of its children.
static
<C extends java.awt.Component>
C
setFontSize(C component, int fontSize)
          Sets font size of the specified component.
static
<C extends java.awt.Component>
C
setFontSizeAndStyle(C component, int fontSize, boolean bold, boolean italic)
          Sets font size and style for the specified component.
static
<C extends java.awt.Component>
C
setFontSizeAndStyle(C component, int fontSize, int style)
          Sets font size and style for the specified component.
static
<C extends java.awt.Component>
C
setFontStyle(C component, boolean bold, boolean italic)
          Sets font style for the specified component.
static
<C extends java.awt.Component>
C
setFontStyle(C component, int style)
          Sets font style for the specified component.
static void setForegroundRecursively(javax.swing.JComponent component, java.awt.Color foreground)
          Sets foreground color of component and all of its children.
static void setForegroundRecursively(javax.swing.JComponent component, java.awt.Color foreground, boolean childsOnly)
          Sets foreground color of component and all of its children.
static void setHandlesEnableStateMark(javax.swing.JComponent component)
          Adds HANDLES_ENABLE_STATE mark into component client properties.
static
<C extends java.awt.Component>
C
setItalicFont(C component)
          Changes font to italic for the specified component.
static
<C extends java.awt.Component>
C
setItalicFont(C component, boolean apply)
          Changes font to italic for the specified component.
static void setOpaqueRecursively(java.awt.Component component, boolean opaque)
          Sets opaque state of component and all of its children.
static void setOpaqueRecursively(java.awt.Component component, boolean opaque, boolean childsOnly)
          Sets opaque state of component and all of its children.
static void setOrientation(java.awt.Component component)
          Sets component orientation to specified component.
static void setOrientation(java.awt.Component component, boolean forced)
          Sets component orientation to specified component if needed or if forced.
static
<C extends java.awt.Component>
C
setPlainFont(C component)
          Changes font to plain for the specified component.
static
<C extends java.awt.Component>
C
setPlainFont(C component, boolean apply)
          Changes font to plain for the specified component.
static java.util.Map setupTextAntialias(java.awt.Graphics g)
          Installs text antialiasing hints into specified graphics context.
static java.util.Map setupTextAntialias(java.awt.Graphics2D g2d)
          Installs text antialiasing hints into specified graphics context.
static java.util.Map setupTextAntialias(java.awt.Graphics2D g2d, java.util.Map hints)
          Installs text antialiasing hints into specified graphics context.
static java.util.Map setupTextAntialias(java.awt.Graphics g, java.util.Map hints)
          Installs text antialiasing hints into specified graphics context.
static void showAsModal(java.awt.Frame frame, java.awt.Frame owner)
          Displays the specified frame as modal to the owner frame.
static java.awt.Rectangle size(java.awt.Component component)
          Returns component size represented as a rectangle with zero X and Y coordinates.
static int stringWidth(java.awt.FontMetrics fm, java.lang.String string)
          Returns the width of the passed in String.
static java.awt.Insets toRTL(java.awt.Insets insets)
          Returns insets converted into RTL orientation.
static void updateGlobalOrientations()
          Updates component orientation for all existing components.
static void updateGlobalOrientations(java.awt.ComponentOrientation orientation)
          Sets specified component orientation for all existing components.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HANDLES_ENABLE_STATE

public static final java.lang.String HANDLES_ENABLE_STATE
Client property key that identifies that component can handle enabled state changes.

See Also:
Constant Field Values
Constructor Detail

SwingUtils

public SwingUtils()
Method Detail

isPreserveBorders

public static boolean isPreserveBorders(javax.swing.JComponent component)
Returns whether UI delegate should preserve current border on this component or not.

Parameters:
component - component to process
Returns:
true if UI delegate should preserve current border on this component, false otherwise

getHonorUserBorders

public static boolean getHonorUserBorders(javax.swing.JComponent component)
Returns whether UI delegate should honor a user-specified border on this component or not.

Parameters:
component - component to process
Returns:
true if UI delegate should honor a user-specified border on this component, false otherwise

isLafDecorated

public static boolean isLafDecorated(java.awt.Component component)
Returns whether window in which specified component located is decorated by L&F or not.

Parameters:
component - component used to determine window decoration state
Returns:
true if window in which specified component located is decorated by L&F, false otherwise

isLeftMouseButton

public static boolean isLeftMouseButton(java.awt.event.MouseEvent e)
Returns whether event involves left mouse button or not.

Parameters:
e - mouse event
Returns:
true if event involves left mouse button, false otherwise

isMiddleMouseButton

public static boolean isMiddleMouseButton(java.awt.event.MouseEvent e)
Returns whether event involves middle mouse button or not.

Parameters:
e - mouse event
Returns:
true if event involves middle mouse button, false otherwise

isRightMouseButton

public static boolean isRightMouseButton(java.awt.event.MouseEvent e)
Returns whether event involves right mouse button or not.

Parameters:
e - mouse event
Returns:
true if event involves right mouse button, false otherwise

packRowHeights

public static void packRowHeights(javax.swing.JTable table)
Packs all table rows to their preferred height.

Parameters:
table - table to process

packColumnWidths

public static void packColumnWidths(javax.swing.JTable table)
Packs all table columns to their preferred width.

Parameters:
table - table to process

packColumnWidths

public static void packColumnWidths(javax.swing.JTable table,
                                    int margin)
Packs all table columns to their preferred width.

Parameters:
table - table to process
margin - column side margin

packColumnWidth

public static void packColumnWidth(javax.swing.JTable table,
                                   int col)
Packs table column at the specified index to its preferred width.

Parameters:
table - table to process
col - column index

packColumnWidth

public static void packColumnWidth(javax.swing.JTable table,
                                   int col,
                                   int margin)
Packs table column at the specified index to its preferred width.

Parameters:
table - table to process
col - column index
margin - column side margin

isPopupTrigger

public static boolean isPopupTrigger(java.awt.event.MouseEvent e)
Returns whether the specifid mouse events triggers popup menu or not. This method might act differently on different operating systems.

Parameters:
e - mouse event
Returns:
true if the specifid mouse events triggers popup menu, false otherwise

destroyContainer

public static void destroyContainer(java.awt.Container container)
Destroys container by destroying its childs structure and removing all listeners.

Parameters:
container - container to destroy

collectAllContainers

public static java.util.List<java.awt.Container> collectAllContainers(java.awt.Container container)
Returns list of all sub-containers for this container.

Parameters:
container - container to process
Returns:
list of all sub-containers

collectAllContainers

public static java.util.List<java.awt.Container> collectAllContainers(java.awt.Container container,
                                                                      java.util.List<java.awt.Container> containers)
Returns list of all sub-containers for this container.

Parameters:
container - container to process
containers - list to collect sub-containers into
Returns:
list of all sub-containers

getTopComponentAt

public static java.awt.Component getTopComponentAt(java.awt.Component component,
                                                   int x,
                                                   int y)
Returns top component inside the specified container component at the specified point.

Parameters:
component - container component to process
x - X coordinate
y - Y coordinate
Returns:
top component inside the specified container component at the specified point

showAsModal

public static void showAsModal(java.awt.Frame frame,
                               java.awt.Frame owner)
Displays the specified frame as modal to the owner frame. Note that this method returns only after the modal frame is closed.

This method is a Swing hack and not recommended for real use. Still it might be useful for some specific cases.

Parameters:
frame - frame to display as modal
owner - owner frame

groupButtons

public static javax.swing.ButtonGroup groupButtons(java.awt.Container container)
Groups all buttons inside this container and returns created button group.

Parameters:
container - container to process
Returns:
created button group

groupButtons

public static javax.swing.ButtonGroup groupButtons(java.awt.Container container,
                                                   boolean recursive)
Groups all buttons inside this container and all subcontainers if requested and returns created button group.

Parameters:
container - container to process
recursive - whether to check all subcontainers or not
Returns:
created button group

groupButtons

public static void groupButtons(java.awt.Container container,
                                boolean recursive,
                                javax.swing.ButtonGroup buttonGroup)
Groups all buttons inside this container and all subcontainers if requested and returns created button group.

Parameters:
container - container to process
recursive - whether to check all subcontainers or not
buttonGroup - button group

groupButtons

public static javax.swing.ButtonGroup groupButtons(javax.swing.AbstractButton... buttons)
Groups specified buttons and returns created button group.

Parameters:
buttons - buttons to group
Returns:
created button group

groupButtons

public static void groupButtons(javax.swing.ButtonGroup buttonGroup,
                                javax.swing.AbstractButton... buttons)
Groups buttons in the specified button group.

Parameters:
buttonGroup - button group
buttons - buttons to group

copyOrientation

public static void copyOrientation(java.awt.Component from,
                                   java.awt.Component to)
Copies component orientation from one component to another.

Parameters:
from - component to copy orientation from
to - component to copy orientation into

updateGlobalOrientations

public static void updateGlobalOrientations()
Updates component orientation for all existing components.


updateGlobalOrientations

public static void updateGlobalOrientations(java.awt.ComponentOrientation orientation)
Sets specified component orientation for all existing components.

Parameters:
orientation - component orientation to set

setOrientation

public static void setOrientation(java.awt.Component component)
Sets component orientation to specified component.

Parameters:
component - component to modify

setOrientation

public static void setOrientation(java.awt.Component component,
                                  boolean forced)
Sets component orientation to specified component if needed or if forced.

Parameters:
component - component to modify
forced - force orientation change

applyOrientation

public static void applyOrientation(java.awt.Component component)
Applies component orientation to specified component.

Parameters:
component - component to modify

applyOrientation

public static void applyOrientation(java.awt.Component component,
                                    boolean forced)
Applies component orientation to specified component if needed or if forced.

Parameters:
component - component to modify
forced - force orientation change

maxWidth

public static int maxWidth(java.awt.Component... components)
Returns maximum component width.

Parameters:
components - components to process
Returns:
maximum component width

maxHeight

public static int maxHeight(java.awt.Component... components)
Returns maximum component height.

Parameters:
components - components to process
Returns:
maximum component height

isHeavyWeightWindow

public static boolean isHeavyWeightWindow(java.awt.Window window)
Returns whether specified window is a HeavyWeightWindow or not.

Parameters:
window - window to process
Returns:
true if specified window is a HeavyWeightWindow, false otherwise

getFirstParent

public static <T> T getFirstParent(java.awt.Component component,
                                   java.lang.Class<T> parentClass)
Returns first parent which is instance of specified class type or null if none found.

Type Parameters:
T - parent component class type
Parameters:
component - component to look parent for
parentClass - parent component class
Returns:
first parent which is instance of specified class type or null if none found

getWindowAncestor

public static java.awt.Window getWindowAncestor(java.awt.Component component)
Returns window ancestor for specified component or null if it doesn't exist.

Parameters:
component - component to process
Returns:
window ancestor for specified component or null if it doesn't exist

getRootPane

public static javax.swing.JRootPane getRootPane(java.awt.Component component)
Returns root pane for the specified component or null if it doesn't exist.

Parameters:
component - component to look under
Returns:
root pane for the specified component or null if it doesn't exist

getContentPane

public static java.awt.Container getContentPane(java.awt.Component component)
Returns content pane for the specified component or null if it doesn't exist.

Parameters:
component - component to look under
Returns:
content pane for the specified component or null if it doesn't exist

getLayeredPane

public static javax.swing.JLayeredPane getLayeredPane(java.awt.Component component)
Returns layered pane for the specified component or null if it doesn't exist.

Parameters:
component - component to look under
Returns:
layered pane for the specified component or null if it doesn't exist

getGlassPane

public static java.awt.Component getGlassPane(java.awt.Component component)
Returns glass pane for the specified component or null if it doesn't exist.

Parameters:
component - component to look under
Returns:
glass pane for the specified component or null if it doesn't exist

setBorder

public static <C extends javax.swing.JComponent> C setBorder(C component,
                                                             int border)
Sets an empty border for the specified component.

Type Parameters:
C - component type
Parameters:
component - component to modify
border - component border
Returns:
modified component

setBorder

public static <C extends javax.swing.JComponent> C setBorder(C component,
                                                             int top,
                                                             int left,
                                                             int bottom,
                                                             int right)
Sets an empty border for the specified component.

Type Parameters:
C - component type
Parameters:
component - component to modify
top - component top border
left - component left border
bottom - component bottom border
right - component right border
Returns:
modified component

setBorder

public static <C extends javax.swing.JComponent> C setBorder(C component,
                                                             javax.swing.border.Border border)
Sets border for the specified component.

Type Parameters:
C - component type
Parameters:
component - component to modify
border - component border
Returns:
modified component

isPlainFont

public static boolean isPlainFont(java.awt.Component component)
Returns whether component font is plain or not.

Parameters:
component - component to process
Returns:
true if component font is plain, false otherwise

setPlainFont

public static <C extends java.awt.Component> C setPlainFont(C component)
Changes font to plain for the specified component.

Type Parameters:
C - component type
Parameters:
component - component to modify
Returns:
modified component

setPlainFont

public static <C extends java.awt.Component> C setPlainFont(C component,
                                                            boolean apply)
Changes font to plain for the specified component.

Type Parameters:
C - component type
Parameters:
component - component to modify
apply - whether to apply font changes or not
Returns:
modified component

isBoldFont

public static boolean isBoldFont(java.awt.Component component)
Returns whether component font is bold or not.

Parameters:
component - component to process
Returns:
true if component font is bold, false otherwise

setBoldFont

public static <C extends java.awt.Component> C setBoldFont(C component)
Changes font to bold for the specified component.

Type Parameters:
C - component type
Parameters:
component - component to modify
Returns:
modified component

setBoldFont

public static <C extends java.awt.Component> C setBoldFont(C component,
                                                           boolean apply)
Changes font to bold for the specified component.

Type Parameters:
C - component type
Parameters:
component - component to modify
apply - whether to apply font changes or not
Returns:
modified component

isItalicFont

public static boolean isItalicFont(java.awt.Component component)
Returns whether component font is italic or not.

Parameters:
component - component to process
Returns:
true if component font is italic, false otherwise

setItalicFont

public static <C extends java.awt.Component> C setItalicFont(C component)
Changes font to italic for the specified component.

Type Parameters:
C - component type
Parameters:
component - component to modify
Returns:
modified component

setItalicFont

public static <C extends java.awt.Component> C setItalicFont(C component,
                                                             boolean apply)
Changes font to italic for the specified component.

Type Parameters:
C - component type
Parameters:
component - component to modify
apply - whether to apply font changes or not
Returns:
modified component

setFontSize

public static <C extends java.awt.Component> C setFontSize(C component,
                                                           int fontSize)
Sets font size of the specified component.

Type Parameters:
C - component type
Parameters:
component - component to modify
fontSize - new font size
Returns:
modified component

changeFontSize

public static <C extends java.awt.Component> C changeFontSize(C component,
                                                              int change)
Changes font size of the specified component.

Type Parameters:
C - component type
Parameters:
component - component to modify
change - font size change amount
Returns:
modified component

getFontSize

public static int getFontSize(java.awt.Component component)
Returns font size of the specified component.

Parameters:
component - component to process
Returns:
font size of the specified component

setFontStyle

public static <C extends java.awt.Component> C setFontStyle(C component,
                                                            boolean bold,
                                                            boolean italic)
Sets font style for the specified component.

Type Parameters:
C - component type
Parameters:
component - component to modify
bold - whether should set bold font or not
italic - whether should set italic font or not
Returns:
modified component

setFontStyle

public static <C extends java.awt.Component> C setFontStyle(C component,
                                                            int style)
Sets font style for the specified component.

Type Parameters:
C - component type
Parameters:
component - component to modify
style - new style
Returns:
modified component

setFontSizeAndStyle

public static <C extends java.awt.Component> C setFontSizeAndStyle(C component,
                                                                   int fontSize,
                                                                   boolean bold,
                                                                   boolean italic)
Sets font size and style for the specified component.

Type Parameters:
C - component type
Parameters:
component - component to modify
fontSize - new font size
bold - whether should set bold font or not
italic - whether should set italic font or not
Returns:
modified component

setFontSizeAndStyle

public static <C extends java.awt.Component> C setFontSizeAndStyle(C component,
                                                                   int fontSize,
                                                                   int style)
Sets font size and style for the specified component.

Type Parameters:
C - component type
Parameters:
component - component to modify
fontSize - new font size
style - new style
Returns:
modified component

setFontName

public static <C extends java.awt.Component> C setFontName(C component,
                                                           java.lang.String fontName)
Sets component font name.

Type Parameters:
C - component type
Parameters:
component - component font name
fontName - new font name
Returns:
modified component

getFontName

public static java.lang.String getFontName(java.awt.Component component)
Returns component font name.

Parameters:
component - component to process
Returns:
component font name

copy

public static java.awt.Dimension copy(java.awt.Dimension dimension)
Returns dimension copy.

Parameters:
dimension - dimension to copy
Returns:
dimension copy

copy

public static java.awt.Point copy(java.awt.Point point)
Returns point copy.

Parameters:
point - point to copy
Returns:
point copy

copy

public static java.awt.Rectangle copy(java.awt.Rectangle rectangle)
Returns rectangle copy.

Parameters:
rectangle - rectangle to copy
Returns:
rectangle copy

copy

public static java.awt.Insets copy(java.awt.Insets insets)
Returns insets copy.

Parameters:
insets - insets to copy
Returns:
insets copy

copy

public static java.awt.Color copy(java.awt.Color color)
Returns color copy.

Parameters:
color - color to copy
Returns:
color copy

size

public static java.awt.Rectangle size(java.awt.Component component)
Returns component size represented as a rectangle with zero X and Y coordinates.

Parameters:
component - component to process
Returns:
component size rectangle

contentSize

public static java.awt.Rectangle contentSize(java.awt.Component component)
Returns component content size limited by component border.

Parameters:
component - component to process
Returns:
component content size rectangle

max

public static java.awt.Insets max(java.awt.Insets insets1,
                                  java.awt.Insets insets2)
Returns maximum insets combined from the specified ones.

Parameters:
insets1 - first insets
insets2 - second insets
Returns:
maximum insets

min

public static java.awt.Insets min(java.awt.Insets insets1,
                                  java.awt.Insets insets2)
Returns minimum insets combined from the specified ones.

Parameters:
insets1 - first insets
insets2 - second insets
Returns:
minimum insets

max

public static java.awt.Dimension max(java.awt.Component component1,
                                     java.awt.Component component2)
Returns maximum dimension combined from specified components dimensions.

Parameters:
component1 - first component
component2 - second component
Returns:
maximum dimension

max

public static java.awt.Dimension max(java.awt.Component... components)
Returns maximum dimension combined from specified components dimensions.

Parameters:
components - components
Returns:
maximum dimension

max

public static java.awt.Dimension max(java.awt.Dimension dimension1,
                                     java.awt.Dimension dimension2)
Returns maximum dimension combined from specified ones.

Parameters:
dimension1 - first dimension
dimension2 - second dimension
Returns:
maximum dimension

min

public static java.awt.Dimension min(java.awt.Component component1,
                                     java.awt.Component component2)
Returns minimum dimension combined from specified components dimensions.

Parameters:
component1 - first component
component2 - second component
Returns:
minimum dimension

min

public static java.awt.Dimension min(java.awt.Dimension dimension1,
                                     java.awt.Dimension dimension2)
Returns minimum dimension combined from specified ones.

Parameters:
dimension1 - first dimension
dimension2 - second dimension
Returns:
minimum dimension

setOpaqueRecursively

public static void setOpaqueRecursively(java.awt.Component component,
                                        boolean opaque)
Sets opaque state of component and all of its children.

Parameters:
component - component to modify
opaque - whether opaque state or not

setOpaqueRecursively

public static void setOpaqueRecursively(java.awt.Component component,
                                        boolean opaque,
                                        boolean childsOnly)
Sets opaque state of component and all of its children.

Parameters:
component - component to modify
opaque - whether opaque state or not
childsOnly - whether exclude component from changes or not

setDoubleBufferedRecursively

public static void setDoubleBufferedRecursively(java.awt.Component component,
                                                boolean doubleBuffered)
Sets double buffered state of component and all of its children.

Parameters:
component - component to modify
doubleBuffered - whether use double buffering or not

setDoubleBufferedRecursively

public static void setDoubleBufferedRecursively(java.awt.Component component,
                                                boolean doubleBuffered,
                                                boolean childsOnly)
Sets double buffered state of component and all of its children.

Parameters:
component - component to modify
doubleBuffered - whether use double buffering or not
childsOnly - whether exclude component from changes or not

setHandlesEnableStateMark

public static void setHandlesEnableStateMark(javax.swing.JComponent component)
Adds HANDLES_ENABLE_STATE mark into component client properties.

Parameters:
component - component to process

removeHandlesEnableStateMark

public static void removeHandlesEnableStateMark(javax.swing.JComponent component)
Removes HANDLES_ENABLE_STATE mark from component client properties.

Parameters:
component - component to process

isHandlesEnableState

public static boolean isHandlesEnableState(java.awt.Component component)
Returns whether HANDLES_ENABLE_STATE mark is set in this component to true or not.

Parameters:
component - component to process
Returns:
true if HANDLES_ENABLE_STATE mark is set in this component to true, false otherwise

setEnabledRecursively

public static void setEnabledRecursively(java.awt.Component component,
                                         boolean enabled)
Sets enabled state of component and all of its children.

Parameters:
component - component to modify
enabled - whether component is enabled or not

setEnabledRecursively

public static void setEnabledRecursively(java.awt.Component component,
                                         boolean enabled,
                                         boolean startFromChilds)
Sets enabled state of component and all of its children.

Parameters:
component - component to modify
enabled - whether component is enabled or not
startFromChilds - whether exclude component from changes or not

disableRecursively

public static java.util.List<java.awt.Component> disableRecursively(java.awt.Component component,
                                                                    boolean startFromChilds,
                                                                    boolean excludePanels,
                                                                    java.awt.Component... excluded)
Disables component and all of its children recursively.

Parameters:
component - component to disable
startFromChilds - whether should disable only component childs or not
excludePanels - whether should exclude panels from disabling or not
excluded - components to exclude from disabling
Returns:
list of actually disabled components

disableRecursively

public static java.util.List<java.awt.Component> disableRecursively(java.awt.Component component,
                                                                    boolean startFromChilds,
                                                                    boolean excludePanels,
                                                                    java.util.List<java.awt.Component> excluded)
Disables component and all of its children recursively.

Parameters:
component - component to disable
startFromChilds - whether should disable only component childs or not
excludePanels - whether should exclude panels from disabling or not
excluded - components to exclude from disabling
Returns:
list of actually disabled components

enable

public static void enable(java.util.List<java.awt.Component> disabled)
Enables specified components.

Parameters:
disabled - disabled components list

setFocusableRecursively

public static void setFocusableRecursively(javax.swing.JComponent component,
                                           boolean focusable)
Sets focusable state of component and all of its children.

Parameters:
component - component to modify
focusable - whether component is focusable or not

setFocusableRecursively

public static void setFocusableRecursively(javax.swing.JComponent component,
                                           boolean focusable,
                                           boolean childsOnly)
Sets focusable state of component and all of its children.

Parameters:
component - component to modify
focusable - whether component is focusable or not
childsOnly - whether exclude component from changes or not

setBackgroundRecursively

public static void setBackgroundRecursively(java.awt.Component component,
                                            java.awt.Color bg)
Sets background color of component and all of its children.

Parameters:
component - component to modify
bg - new background color

setBackgroundRecursively

public static void setBackgroundRecursively(java.awt.Component component,
                                            java.awt.Color bg,
                                            boolean childsOnly)
Sets background color of component and all of its children.

Parameters:
component - component to modify
bg - new background color
childsOnly - whether exclude component from changes or not

setForegroundRecursively

public static void setForegroundRecursively(javax.swing.JComponent component,
                                            java.awt.Color foreground)
Sets foreground color of component and all of its children.

Parameters:
component - component to modify
foreground - new foreground color

setForegroundRecursively

public static void setForegroundRecursively(javax.swing.JComponent component,
                                            java.awt.Color foreground,
                                            boolean childsOnly)
Sets foreground color of component and all of its children.

Parameters:
component - component to modify
foreground - new foreground color
childsOnly - whether exclude component from changes or not

setFontRecursively

public static void setFontRecursively(javax.swing.JComponent component,
                                      java.awt.Font font)
Sets font of component and all of its children.

Parameters:
component - component to modify
font - new font

setFontRecursively

public static void setFontRecursively(javax.swing.JComponent component,
                                      java.awt.Font font,
                                      boolean childsOnly)
Sets font of component and all of its children.

Parameters:
component - component to modify
font - new font
childsOnly - whether exclude component from changes or not

createComponentSnapshot

public static java.awt.image.BufferedImage createComponentSnapshot(java.awt.Component content)
Returns component snapshot image. Component must be showing to render properly using this method.

Parameters:
content - component for snapshot
Returns:
component snapshot image

createComponentSnapshot

public static java.awt.image.BufferedImage createComponentSnapshot(java.awt.Component content,
                                                                   int width,
                                                                   int height)
Returns component snapshot image of specified size. Component must be showing to render properly using this method.

Parameters:
content - component for snapshot
width - snapshot image width
height - snapshot image height
Returns:
component snapshot image

setAccelerator

public static void setAccelerator(javax.swing.JMenuItem menuItem,
                                  HotkeyData hotkey)
Sets menu item accelerator using the specified hotkey data.

Parameters:
menuItem - menu item
hotkey - hotkey data

getActiveWindow

public static java.awt.Window getActiveWindow()
Returns active application window.

Returns:
active application window

isShortcut

public static boolean isShortcut(java.awt.event.InputEvent event)
Returns whether specified event contains shortcut modifier or not.

Parameters:
event - event to process
Returns:
true if specified event contains shortcut modifier, false otherwise

getSystemShortcutModifier

public static int getSystemShortcutModifier()
Returns system shortcut modifier.

Returns:
system shortcut modifier

hotkeyToString

public static java.lang.String hotkeyToString(java.awt.event.KeyEvent keyEvent)
Returns readable form of hotkey triggered by specified key event.

Parameters:
keyEvent - key event to process
Returns:
readable form of hotkey triggered by specified key event

hotkeyToString

public static java.lang.String hotkeyToString(HotkeyData hotkeyData)
Returns readable form of specified hotkey data.

Parameters:
hotkeyData - hotkey data to process
Returns:
readable form of specified hotkey data

hotkeyToString

public static java.lang.String hotkeyToString(javax.swing.KeyStroke keyStroke)
Returns readable form of specified key stroke.

Parameters:
keyStroke - key stroke to process
Returns:
readable form of specified key stroke

hotkeyToString

public static java.lang.String hotkeyToString(boolean isCtrl,
                                              boolean isAlt,
                                              boolean isShift,
                                              java.lang.Integer keyCode)
Returns readable form for specified hotkey.

Parameters:
isCtrl - whether hotkey requires CTRL modifier or not
isAlt - whether hotkey requires ALT modifier or not
isShift - whether hotkey requires SHIFT modifier or not
keyCode - key code for hotkey
Returns:
readable form for specified hotkey

isCtrl

public static boolean isCtrl(java.awt.event.InputEvent event)
Returns whether CTRL modifier is triggered by the specified event or not.

Parameters:
event - event to process
Returns:
true if CTRL modifier is triggered by the specified event, false otherwise

isCtrl

public static boolean isCtrl(int modifiers)
Returns whether CTRL modifier is triggered by the specified modifiers or not.

Parameters:
modifiers - modifiers to process
Returns:
true if CTRL modifier is triggered by the specified modifiers, false otherwise

isAlt

public static boolean isAlt(java.awt.event.InputEvent event)
Returns whether ALT modifier is triggered by the specified event or not.

Parameters:
event - event to process
Returns:
true if ALT modifier is triggered by the specified event, false otherwise

isAlt

public static boolean isAlt(int modifiers)
Returns whether ALT modifier is triggered by the specified modifiers or not.

Parameters:
modifiers - modifiers to process
Returns:
true if ALT modifier is triggered by the specified modifiers, false otherwise

isShift

public static boolean isShift(java.awt.event.InputEvent event)
Returns whether SHIFT modifier is triggered by the specified event or not.

Parameters:
event - event to process
Returns:
true if SHIFT modifier is triggered by the specified event, false otherwise

isShift

public static boolean isShift(int modifiers)
Returns whether SHIFT modifier is triggered by the specified modifiers or not.

Parameters:
modifiers - modifiers to process
Returns:
true if SHIFT modifier is triggered by the specified modifiers, false otherwise

getHotkeyData

public static HotkeyData getHotkeyData(javax.swing.KeyStroke keyStroke)
Returns hotkey data extracted from the specified key stroke.

Parameters:
keyStroke - key stroke to process
Returns:
hotkey data

getDefaultLabelFont

public static java.awt.Font getDefaultLabelFont()
Returns default label font. This method might be used as a hack with other L&Fs to retrieve system default font for simple text.

Returns:
default label font

getScrollPane

public static javax.swing.JScrollPane getScrollPane(java.awt.Component component)
Returns scroll pane for specified component if exists, null otherwise.

Parameters:
component - component to process
Returns:
scroll pane for specified component if exists, null otherwise

findFocusableComponent

public static java.awt.Component findFocusableComponent(java.awt.Container container)
Returns first focusable component found in the container.

Parameters:
container - container to process
Returns:
first focusable component found in the container

findComponentsWithText

public static java.util.List<java.awt.Component> findComponentsWithText(java.lang.String text,
                                                                        java.awt.Component component)
Returns list of all components that visually contains the specified text.

Parameters:
text - text to find
component - component or container to look for specified text
Returns:
list of all components that visually contains the specified text

findComponentsWithText

public static java.util.List<java.awt.Component> findComponentsWithText(java.lang.String text,
                                                                        java.awt.Component component,
                                                                        java.util.List<java.awt.Component> components)
Returns list of all components that visually contains the specified text.

Parameters:
text - text to find
component - component or container to look for specified text
components - list of found components
Returns:
list of all components that visually contains the specified text

getBoundsOnScreen

public static java.awt.Rectangle getBoundsOnScreen(java.awt.Component component)
Returns component bounds on screen.

Parameters:
component - component to process
Returns:
component bounds on screen

getBoundsInWindow

public static java.awt.Rectangle getBoundsInWindow(java.awt.Component component)
Returns component bounds inside its window. This will return component bounds relative to window root pane location, not the window location.

Parameters:
component - component to process
Returns:
component bounds inside its window

getRelativeBounds

public static java.awt.Rectangle getRelativeBounds(java.awt.Component component,
                                                   java.awt.Component relativeTo)
Returns component bounds relative to another component.

Parameters:
component - component to process
relativeTo - component relative to which bounds will be returned
Returns:
component bounds relative to another component

getRelativeLocation

public static java.awt.Point getRelativeLocation(java.awt.Component component,
                                                 java.awt.Component relativeTo)
Returns component location relative to another component.

Parameters:
component - component to process
relativeTo - component relative to which location will be returned
Returns:
component location relative to another component

isSameAncestor

public static boolean isSameAncestor(java.awt.Component component1,
                                     java.awt.Component component2)
Returns whether specified components have the same ancestor or not.

Parameters:
component1 - first component
component2 - second component
Returns:
true if specified components have the same ancestor, false otherwise

getChildPreferredSizes

public static java.util.Map<java.awt.Component,java.awt.Dimension> getChildPreferredSizes(java.awt.Container container)
Returns map of container child components preferred sizes.

Parameters:
container - container to process
Returns:
map of container child components preferred sizes

equalizeComponentsSize

public static void equalizeComponentsSize(java.awt.Component... components)
Makes all specified component sizes equal.

Parameters:
components - components to modify

equalizeComponentsWidths

public static void equalizeComponentsWidths(java.awt.Component... components)
Makes all specified component widths equal.

Parameters:
components - components to modify

equalizeComponentsHeights

public static void equalizeComponentsHeights(java.awt.Component... components)
Makes all specified component heights equal.

Parameters:
components - components to modify

isEqualOrChild

public static boolean isEqualOrChild(java.awt.Component component1,
                                     java.awt.Component component2)
Returns whether the first component or any of its children are equal to second component or not.

Parameters:
component1 - first component to compare
component2 - second component to compare
Returns:
true if the first component or any of its children are equal to second component, false otherwise

hasFocusOwner

public static boolean hasFocusOwner(java.awt.Component component)
Returns whether component or any of its children has focus or not.

Parameters:
component - component to process
Returns:
true if component or any of its children has focus, false otherwise

hasFocusableComponent

public static boolean hasFocusableComponent(java.awt.Container container)
Returns whether atleast one of child components within the specified container is focusable or not.

Parameters:
container - container to process
Returns:
true if atleast one of child components within the specified container is focusable, false otherwise

getFontNames

public static java.lang.String[] getFontNames()
Returns system font names array.

Returns:
system font names array

getFonts

public static java.awt.Font[] getFonts()
Returns system fonts array.

Returns:
system fonts array

createFonts

public static java.awt.Font[] createFonts(java.lang.String[] fontNames)
Returns an array of fonts created using specified array of font names.

Parameters:
fontNames - array of font names
Returns:
an array of fonts

delayInvokeLater

public static void delayInvokeLater(long delay,
                                    java.lang.Runnable runnable)
Will perform an "invokeLater" call when the specified delay time passes.

Parameters:
delay - delay time in milliseconds
runnable - runnable

invokeLater

public static void invokeLater(java.lang.Runnable runnable)
Will invoke the specified action later in EDT in case it is called from non-EDT thread. Otherwise action will be performed immediately.

Parameters:
runnable - runnable

invokeLater

public static void invokeLater(HotkeyRunnable runnable,
                               java.awt.event.KeyEvent e)
Will invoke the specified action later in EDT in case it is called from non-EDT thread. Otherwise action will be performed immediately.

Parameters:
runnable - hotkey runnable
e - key event

invokeAndWait

public static void invokeAndWait(java.lang.Runnable runnable)
                          throws java.lang.InterruptedException,
                                 java.lang.reflect.InvocationTargetException
Will invoke the specified action in EDT in case it is called from non-EDT thread.

Parameters:
runnable - runnable
Throws:
java.lang.InterruptedException
java.lang.reflect.InvocationTargetException

invokeAndWaitSafely

public static void invokeAndWaitSafely(java.lang.Runnable runnable)
Will invoke the specified action in EDT in case it is called from non-EDT thread. It will also block any exceptions thrown by "invokeAndWait" method.

Parameters:
runnable - runnable

toRTL

public static java.awt.Insets toRTL(java.awt.Insets insets)
Returns insets converted into RTL orientation.

Parameters:
insets - insets to convert
Returns:
insets converted into RTL orientation

getMousePoint

public static java.awt.Point getMousePoint(java.awt.Component component)
Returns mouse point relative to specified component.

Parameters:
component - component to process
Returns:
mouse point relative to specified component

scrollSmoothly

public static void scrollSmoothly(javax.swing.JScrollPane scrollPane,
                                  int xValue,
                                  int yValue)
Scrolls scroll pane visible area smoothly to destination values.

Parameters:
scrollPane - scroll pane to scroll through
xValue - horiontal scroll bar value
yValue - vertical scroll bar value

drawStringUnderlineCharAt

public static void drawStringUnderlineCharAt(java.awt.Graphics g,
                                             java.lang.String text,
                                             int underlinedIndex,
                                             int x,
                                             int y)
Paints string with underlined character at the specified index.

Parameters:
g - graphics context
text - painted text
underlinedIndex - underlined character index
x - text X coordinate
y - text Y coordinate

drawString

public static void drawString(java.awt.Graphics g,
                              java.lang.String text,
                              int x,
                              int y)
Paints string.

Parameters:
g - graphics context
text - painted text
x - text X coordinate
y - text Y coordinate

setupTextAntialias

public static java.util.Map setupTextAntialias(java.awt.Graphics g)
Installs text antialiasing hints into specified graphics context.

Parameters:
g - graphics context
Returns:
old text antialiasing hints

setupTextAntialias

public static java.util.Map setupTextAntialias(java.awt.Graphics2D g2d)
Installs text antialiasing hints into specified graphics context.

Parameters:
g2d - graphics context
Returns:
old text antialiasing hints

setupTextAntialias

public static java.util.Map setupTextAntialias(java.awt.Graphics g,
                                               java.util.Map hints)
Installs text antialiasing hints into specified graphics context.

Parameters:
g - graphics context
hints - text antialiasing hints
Returns:
old text antialiasing hints

setupTextAntialias

public static java.util.Map setupTextAntialias(java.awt.Graphics2D g2d,
                                               java.util.Map hints)
Installs text antialiasing hints into specified graphics context.

Parameters:
g2d - graphics context
hints - text antialiasing hints
Returns:
old text antialiasing hints

restoreTextAntialias

public static void restoreTextAntialias(java.awt.Graphics g,
                                        java.util.Map hints)
Restores text antialiasing hints into specified graphics context

Parameters:
g - graphics context
hints - old text antialiasing hints

restoreTextAntialias

public static void restoreTextAntialias(java.awt.Graphics2D g2d,
                                        java.util.Map hints)
Restores text antialiasing hints into specified graphics context

Parameters:
g2d - graphics context
hints - old text antialiasing hints

getFontMetrics

public static java.awt.FontMetrics getFontMetrics(javax.swing.JComponent c,
                                                  java.awt.Graphics g)
Returns the FontMetrics for the current Font of the passed in Graphics. This method is used when a Graphics is available, typically when painting. If a Graphics is not available the JComponent method of the same name should be used.

This does not necessarily return the FontMetrics from the Graphics.

Parameters:
c - JComponent requesting FontMetrics, may be null
g - Graphics Graphics

getFontMetrics

public static java.awt.FontMetrics getFontMetrics(javax.swing.JComponent c,
                                                  java.awt.Graphics g,
                                                  java.awt.Font font)
Returns the FontMetrics for the specified Font. This method is used when a Graphics is available, typically when painting. If a Graphics is not available the JComponent method of the same name should be used.

This does not necessarily return the FontMetrics from the Graphics.

Parameters:
c - JComponent requesting FontMetrics, may be null
g - Graphics Graphics
font - Font to get FontMetrics for

stringWidth

public static int stringWidth(java.awt.FontMetrics fm,
                              java.lang.String string)
Returns the width of the passed in String. If the passed String is null, returns zero.

Parameters:
fm - FontMetrics used to measure the String width
string - String to get the width of

getLeftSideBearing

public static int getLeftSideBearing(javax.swing.JComponent c,
                                     java.awt.FontMetrics fm,
                                     java.lang.String string)
Returns the left side bearing of the first character of string. The left side bearing is calculated from the passed in FontMetrics.

Parameters:
c - JComponent that will display the string
fm - FontMetrics used to measure the String width
string - String to get the left side bearing for

getLeftSideBearing

public static int getLeftSideBearing(javax.swing.JComponent c,
                                     java.awt.FontMetrics fm,
                                     char firstChar)
Returns the left side bearing of the specified character. The left side bearing is calculated from the passed in FontMetrics.

Parameters:
c - JComponent that will display the string
fm - FontMetrics used to measure the String width
firstChar - Character to get the left side bearing for

getRightSideBearing

public static int getRightSideBearing(javax.swing.JComponent c,
                                      java.awt.FontMetrics fm,
                                      java.lang.String string)
Returns the right side bearing of the last character of string. The right side bearing is calculated from the passed in FontMetrics.

Parameters:
c - JComponent that will display the string
fm - FontMetrics used to measure the String width
string - String to get the right side bearing for

getRightSideBearing

public static int getRightSideBearing(javax.swing.JComponent c,
                                      java.awt.FontMetrics fm,
                                      char lastChar)
Returns the right side bearing of the specified character. The right side bearing is calculated from the passed in FontMetrics.

Parameters:
c - JComponent that will display the string
fm - FontMetrics used to measure the String width
lastChar - Character to get the right side bearing for