public final class SwingUtils
extends com.alee.utils.CoreSwingUtils
| Modifier and Type | Field and Description |
|---|---|
static java.awt.font.FontRenderContext |
DEFAULT_FRC |
static java.lang.String |
HANDLES_ENABLE_STATE
Client property key that identifies that component can handle enabled state changes.
|
static java.awt.Color |
RENDERING_FIX_COLOR
Constant transparent color used for text rendering fix.
|
| Constructor and Description |
|---|
SwingUtils() |
| Modifier and Type | Method and Description |
|---|---|
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> |
changeFontSize(C component,
int change)
Changes font size of the specified component.
|
static void |
changeOrientation(java.awt.Component component)
Applies opposite component orientation to the specified component and all of its children.
|
static java.lang.String |
clipString(javax.swing.JComponent c,
java.awt.FontMetrics fm,
java.lang.String string,
int availTextWidth)
Clips the passed in String to the space provided.
|
static java.lang.String |
clipStringIfNecessary(javax.swing.JComponent c,
java.awt.FontMetrics fm,
java.lang.String string,
int availTextWidth)
Clips the passed in String to the space provided.
|
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 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,
float opacity)
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.image.BufferedImage |
createComponentSnapshot(java.awt.Component content,
int width,
int height,
float opacity)
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 children structure and removing all listeners.
|
static java.util.List<java.awt.Component> |
disableRecursively(java.awt.Component component,
boolean startFromChildren,
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 startFromChildren,
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 |
enableEventQueueLogging()
Enables logging of all uncaught exceptions occured within EDT.
|
static void |
equalizeComponentsHeight(java.awt.Component... components)
Makes all specified component heights equal.
|
static void |
equalizeComponentsHeight(java.util.List<? extends java.awt.Component> components)
Makes all specified component heights equal.
|
static void |
equalizeComponentsHeight(java.util.List<java.lang.String> properties,
java.awt.Component... components)
Makes all specified component heights equal.
|
static void |
equalizeComponentsHeight(java.util.List<java.lang.String> properties,
java.util.List<? extends 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 |
equalizeComponentsSize(java.util.List<? extends java.awt.Component> components)
Makes all specified component sizes equal.
|
static void |
equalizeComponentsSize(java.util.List<java.lang.String> properties,
java.awt.Component... components)
Makes all specified component sizes equal.
|
static void |
equalizeComponentsSize(java.util.List<java.lang.String> properties,
java.util.List<? extends java.awt.Component> components)
Makes all specified component sizes equal.
|
static void |
equalizeComponentsWidth(java.awt.Component... components)
Makes all specified component widths equal.
|
static void |
equalizeComponentsWidth(java.util.List<? extends java.awt.Component> components)
Makes all specified component widths equal.
|
static void |
equalizeComponentsWidth(java.util.List<java.lang.String> properties,
java.awt.Component... components)
Makes all specified component widths equal.
|
static void |
equalizeComponentsWidth(java.util.List<java.lang.String> properties,
java.util.List<? extends 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 void |
firePropertyChanged(java.awt.Component component,
java.lang.String property,
java.lang.Object oldValue,
java.lang.Object newValue)
Fires painter property change event.
|
static java.awt.Window |
getActiveWindow()
Returns active application window.
|
static java.awt.Window |
getAvailableWindow()
Returns first available visible 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 java.awt.FontMetrics |
getDefaultLabelFontMetrics()
Returns default label font metrics.
|
static <T extends java.awt.Component> |
getFirst(java.awt.Container container,
java.lang.Class<T> componentClass)
Returns first component placed in the specified container which is instance of specified class type or null if none found.
|
static <T extends java.awt.Component> |
getFirst(java.awt.Container container,
java.lang.Class<T> componentClass,
boolean recursive)
Returns first component placed in the specified container which is instance of specified class type or null if none found.
|
static <T extends java.awt.Container> |
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 <T extends javax.swing.JComponent> |
getFirstParentSupportingDrop(java.awt.Component component)
Returns first parent component which supports drag and drop actions.
|
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.FontRenderContext |
getFontRenderContext(java.awt.Component c,
java.awt.FontMetrics fm)
Returns FontRenderContext associated with Component.
|
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.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 java.awt.Rectangle |
getScreenBounds(java.awt.Component component)
Returns screen bounds within which most part of the specified component is placed.
|
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 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 sub-containers 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 sub-containers if requested and returns created button group.
|
static boolean |
hasFocusableComponent(java.awt.Container container)
Returns whether at least 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 int |
indexOf(java.awt.Container parent,
java.awt.Component child)
Returns component index within the specified parent container.
|
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 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 |
isEmpty(java.awt.Insets insets)
Returns whether or not provided insets are empty.
|
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 |
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 specific 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 boolean |
isUIResource(javax.swing.border.Border border)
Returns whether or not specified border is a UI resource.
|
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 childrenOnly)
Sets background color of component and all of its children.
|
static <C extends java.awt.Component> |
setBoldFont(C component)
Changes font to bold for the specified component.
|
static <C extends java.awt.Component> |
setBoldFont(C component,
boolean apply)
Changes font to bold 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 childrenOnly)
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 startFromChildren)
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 childrenOnly)
Sets focusable state of component and all of its children.
|
static <C extends java.awt.Component> |
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 childrenOnly)
Sets font of component and all of its children.
|
static <C extends java.awt.Component> |
setFontSize(C component,
int fontSize)
Sets font size of the specified component.
|
static <C extends java.awt.Component> |
setFontSizeAndStyle(C component,
int fontSize,
boolean bold,
boolean italic)
Sets font size and style for the specified component.
|
static <C extends java.awt.Component> |
setFontSizeAndStyle(C component,
int fontSize,
int style)
Sets font size and style for the specified component.
|
static <C extends java.awt.Component> |
setFontStyle(C component,
boolean bold,
boolean italic)
Sets font style for the specified component.
|
static <C extends java.awt.Component> |
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 childrenOnly)
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 void |
setHonorUserBorders(javax.swing.JComponent component,
boolean honor)
Sets whether UI delegate should honor a user-specified border on this component or not.
|
static <C extends java.awt.Component> |
setItalicFont(C component)
Changes font to italic for the specified component.
|
static <C extends java.awt.Component> |
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 childrenOnly)
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> |
setPlainFont(C component)
Changes font to plain for the specified component.
|
static <C extends java.awt.Component> |
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 |
shrink(java.awt.Rectangle r,
java.awt.Insets insets)
Returns rectange shrunk by provided insets.
|
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 |
update(java.awt.Component component)
Performs full component view update.
|
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.
|
public static final java.lang.String HANDLES_ENABLE_STATE
public static final java.awt.Color RENDERING_FIX_COLOR
public static final java.awt.font.FontRenderContext DEFAULT_FRC
public static void enableEventQueueLogging()
public static void update(java.awt.Component component)
component - component to updatepublic static boolean isEmpty(java.awt.Insets insets)
null insets are considered as empty as well.insets - insets to processpublic static boolean isPreserveBorders(javax.swing.JComponent component)
component - component to processpublic static boolean isUIResource(javax.swing.border.Border border)
border - border to processpublic static boolean getHonorUserBorders(javax.swing.JComponent component)
component - component to processpublic static void setHonorUserBorders(javax.swing.JComponent component,
boolean honor)
component - component to set property forhonor - whether UI delegate should honor a user-specified border on this component or notpublic static boolean isLeftMouseButton(java.awt.event.MouseEvent e)
e - mouse eventpublic static boolean isMiddleMouseButton(java.awt.event.MouseEvent e)
e - mouse eventpublic static boolean isRightMouseButton(java.awt.event.MouseEvent e)
e - mouse eventpublic static void packRowHeights(javax.swing.JTable table)
table - table to processpublic static void packColumnWidths(javax.swing.JTable table)
table - table to processpublic static void packColumnWidths(javax.swing.JTable table,
int margin)
table - table to processmargin - column side marginpublic static void packColumnWidth(javax.swing.JTable table,
int col)
table - table to processcol - column indexpublic static void packColumnWidth(javax.swing.JTable table,
int col,
int margin)
table - table to processcol - column indexmargin - column side marginpublic static boolean isPopupTrigger(java.awt.event.MouseEvent e)
e - mouse eventpublic static void destroyContainer(java.awt.Container container)
container - container to destroypublic static java.util.List<java.awt.Container> collectAllContainers(java.awt.Container container)
container - container to processpublic static java.util.List<java.awt.Container> collectAllContainers(java.awt.Container container,
java.util.List<java.awt.Container> containers)
container - container to processcontainers - list to collect sub-containers intopublic static java.awt.Component getTopComponentAt(java.awt.Component component,
int x,
int y)
component - container component to processx - X coordinatey - Y coordinatepublic static void showAsModal(java.awt.Frame frame,
java.awt.Frame owner)
This method is a Swing hack and not recommended for real use. Still it might be useful for some specific cases.
frame - frame to display as modalowner - owner framepublic static javax.swing.ButtonGroup groupButtons(java.awt.Container container)
container - container to processpublic static javax.swing.ButtonGroup groupButtons(java.awt.Container container,
boolean recursive)
container - container to processrecursive - whether to check all sub-containers or notpublic static void groupButtons(java.awt.Container container,
boolean recursive,
javax.swing.ButtonGroup buttonGroup)
container - container to processrecursive - whether to check all sub-containers or notbuttonGroup - button grouppublic static javax.swing.ButtonGroup groupButtons(javax.swing.AbstractButton... buttons)
buttons - buttons to grouppublic static void groupButtons(javax.swing.ButtonGroup buttonGroup,
javax.swing.AbstractButton... buttons)
buttonGroup - button groupbuttons - buttons to grouppublic static void copyOrientation(java.awt.Component from,
java.awt.Component to)
from - component to copy orientation fromto - component to copy orientation intopublic static void changeOrientation(java.awt.Component component)
component - component to change orientation forpublic static void updateGlobalOrientations()
public static void updateGlobalOrientations(java.awt.ComponentOrientation orientation)
orientation - component orientation to setpublic static void setOrientation(java.awt.Component component)
component - component to modifypublic static void setOrientation(java.awt.Component component,
boolean forced)
component - component to modifyforced - force orientation changepublic static void applyOrientation(java.awt.Component component)
component - component to modifypublic static void applyOrientation(java.awt.Component component,
boolean forced)
component - component to modifyforced - force orientation changepublic static int maxWidth(java.awt.Component... components)
components - components to processpublic static int maxHeight(java.awt.Component... components)
components - components to processpublic static boolean isHeavyWeightWindow(java.awt.Window window)
window - window to processpublic static <T extends java.awt.Container> T getFirstParent(java.awt.Component component,
java.lang.Class<T> parentClass)
T - parent component class typecomponent - component to look parent forparentClass - parent component classpublic static <T extends java.awt.Component> T getFirst(java.awt.Container container,
java.lang.Class<T> componentClass)
T - component class typecontainer - container to look for component incomponentClass - component classpublic static <T extends java.awt.Component> T getFirst(java.awt.Container container,
java.lang.Class<T> componentClass,
boolean recursive)
T - component class typecontainer - container to look for component incomponentClass - component classrecursive - whether to check all sub-containers or notpublic static <T extends javax.swing.JComponent> T getFirstParentSupportingDrop(java.awt.Component component)
T - parent supporting drop component class typecomponent - component to look parent supporting drop forpublic static javax.swing.JRootPane getRootPane(java.awt.Component component)
component - component to look underpublic static java.awt.Window getAvailableWindow()
public static java.awt.Container getContentPane(java.awt.Component component)
component - component to look underpublic static javax.swing.JLayeredPane getLayeredPane(java.awt.Component component)
component - component to look underpublic static java.awt.Component getGlassPane(java.awt.Component component)
component - component to look underpublic static boolean isPlainFont(java.awt.Component component)
component - component to processpublic static <C extends java.awt.Component> C setPlainFont(C component)
C - component typecomponent - component to modifypublic static <C extends java.awt.Component> C setPlainFont(C component,
boolean apply)
C - component typecomponent - component to modifyapply - whether to apply font changes or notpublic static boolean isBoldFont(java.awt.Component component)
component - component to processpublic static <C extends java.awt.Component> C setBoldFont(C component)
C - component typecomponent - component to modifypublic static <C extends java.awt.Component> C setBoldFont(C component,
boolean apply)
C - component typecomponent - component to modifyapply - whether to apply font changes or notpublic static boolean isItalicFont(java.awt.Component component)
component - component to processpublic static <C extends java.awt.Component> C setItalicFont(C component)
C - component typecomponent - component to modifypublic static <C extends java.awt.Component> C setItalicFont(C component,
boolean apply)
C - component typecomponent - component to modifyapply - whether to apply font changes or notpublic static <C extends java.awt.Component> C setFontSize(C component,
int fontSize)
C - component typecomponent - component to modifyfontSize - new font sizepublic static <C extends java.awt.Component> C changeFontSize(C component,
int change)
C - component typecomponent - component to modifychange - font size change amountpublic static int getFontSize(java.awt.Component component)
component - component to processpublic static <C extends java.awt.Component> C setFontStyle(C component,
boolean bold,
boolean italic)
C - component typecomponent - component to modifybold - whether should set bold font or notitalic - whether should set italic font or notpublic static <C extends java.awt.Component> C setFontStyle(C component,
int style)
C - component typecomponent - component to modifystyle - new stylepublic static <C extends java.awt.Component> C setFontSizeAndStyle(C component,
int fontSize,
boolean bold,
boolean italic)
C - component typecomponent - component to modifyfontSize - new font sizebold - whether should set bold font or notitalic - whether should set italic font or notpublic static <C extends java.awt.Component> C setFontSizeAndStyle(C component,
int fontSize,
int style)
C - component typecomponent - component to modifyfontSize - new font sizestyle - new stylepublic static <C extends java.awt.Component> C setFontName(C component,
java.lang.String fontName)
C - component typecomponent - component font namefontName - new font namepublic static java.lang.String getFontName(java.awt.Component component)
component - component to processpublic static java.awt.Insets max(java.awt.Insets insets1,
java.awt.Insets insets2)
insets1 - first insetsinsets2 - second insetspublic static java.awt.Insets min(java.awt.Insets insets1,
java.awt.Insets insets2)
insets1 - first insetsinsets2 - second insetspublic static java.awt.Dimension max(java.awt.Component component1,
java.awt.Component component2)
component1 - first componentcomponent2 - second componentpublic static java.awt.Dimension max(java.awt.Component... components)
components - componentspublic static java.awt.Dimension max(java.awt.Dimension dimension1,
java.awt.Dimension dimension2)
dimension1 - first dimensiondimension2 - second dimensionpublic static java.awt.Dimension min(java.awt.Component component1,
java.awt.Component component2)
component1 - first componentcomponent2 - second componentpublic static java.awt.Dimension min(java.awt.Dimension dimension1,
java.awt.Dimension dimension2)
dimension1 - first dimensiondimension2 - second dimensionpublic static java.awt.Rectangle shrink(java.awt.Rectangle r,
java.awt.Insets insets)
r - rectange to shrinkinsets - insets used to shrink boundspublic static void setOpaqueRecursively(java.awt.Component component,
boolean opaque)
component - component to modifyopaque - whether opaque state or notpublic static void setOpaqueRecursively(java.awt.Component component,
boolean opaque,
boolean childrenOnly)
component - component to modifyopaque - whether opaque state or notchildrenOnly - whether exclude component from changes or notpublic static void setDoubleBufferedRecursively(java.awt.Component component,
boolean doubleBuffered)
component - component to modifydoubleBuffered - whether use double buffering or notpublic static void setDoubleBufferedRecursively(java.awt.Component component,
boolean doubleBuffered,
boolean childrenOnly)
component - component to modifydoubleBuffered - whether use double buffering or notchildrenOnly - whether exclude component from changes or notpublic static void setHandlesEnableStateMark(javax.swing.JComponent component)
component - component to processpublic static void removeHandlesEnableStateMark(javax.swing.JComponent component)
component - component to processpublic static boolean isHandlesEnableState(java.awt.Component component)
component - component to processpublic static void setEnabledRecursively(java.awt.Component component,
boolean enabled)
component - component to modifyenabled - whether component is enabled or notpublic static void setEnabledRecursively(java.awt.Component component,
boolean enabled,
boolean startFromChildren)
component - component to modifyenabled - whether component is enabled or notstartFromChildren - whether exclude component from changes or notpublic static java.util.List<java.awt.Component> disableRecursively(java.awt.Component component,
boolean startFromChildren,
boolean excludePanels,
java.awt.Component... excluded)
component - component to disablestartFromChildren - whether should disable only component children or notexcludePanels - whether should exclude panels from disabling or notexcluded - components to exclude from disablingpublic static java.util.List<java.awt.Component> disableRecursively(java.awt.Component component,
boolean startFromChildren,
boolean excludePanels,
java.util.List<java.awt.Component> excluded)
component - component to disablestartFromChildren - whether should disable only component children or notexcludePanels - whether should exclude panels from disabling or notexcluded - components to exclude from disablingpublic static void enable(java.util.List<java.awt.Component> disabled)
disabled - disabled components listpublic static void setFocusableRecursively(javax.swing.JComponent component,
boolean focusable)
component - component to modifyfocusable - whether component is focusable or notpublic static void setFocusableRecursively(javax.swing.JComponent component,
boolean focusable,
boolean childrenOnly)
component - component to modifyfocusable - whether component is focusable or notchildrenOnly - whether exclude component from changes or notpublic static void setBackgroundRecursively(java.awt.Component component,
java.awt.Color bg)
component - component to modifybg - new background colorpublic static void setBackgroundRecursively(java.awt.Component component,
java.awt.Color bg,
boolean childrenOnly)
component - component to modifybg - new background colorchildrenOnly - whether exclude component from changes or notpublic static void setForegroundRecursively(javax.swing.JComponent component,
java.awt.Color foreground)
component - component to modifyforeground - new foreground colorpublic static void setForegroundRecursively(javax.swing.JComponent component,
java.awt.Color foreground,
boolean childrenOnly)
component - component to modifyforeground - new foreground colorchildrenOnly - whether exclude component from changes or notpublic static void setFontRecursively(javax.swing.JComponent component,
java.awt.Font font)
component - component to modifyfont - new fontpublic static void setFontRecursively(javax.swing.JComponent component,
java.awt.Font font,
boolean childrenOnly)
component - component to modifyfont - new fontchildrenOnly - whether exclude component from changes or notpublic static java.awt.image.BufferedImage createComponentSnapshot(java.awt.Component content)
content - component for snapshotpublic static java.awt.image.BufferedImage createComponentSnapshot(java.awt.Component content,
float opacity)
content - component for snapshotopacity - snapshot opacitypublic static java.awt.image.BufferedImage createComponentSnapshot(java.awt.Component content,
int width,
int height)
content - component for snapshotwidth - snapshot image widthheight - snapshot image heightpublic static java.awt.image.BufferedImage createComponentSnapshot(java.awt.Component content,
int width,
int height,
float opacity)
content - component for snapshotwidth - snapshot image widthheight - snapshot image heightopacity - snapshot opacitypublic static void setAccelerator(javax.swing.JMenuItem menuItem,
HotkeyData hotkey)
menuItem - menu itemhotkey - hotkey datapublic static java.awt.Window getActiveWindow()
public static boolean isShortcut(java.awt.event.InputEvent event)
event - event to processpublic static int getSystemShortcutModifier()
public static java.lang.String hotkeyToString(java.awt.event.KeyEvent keyEvent)
keyEvent - key event to processpublic static java.lang.String hotkeyToString(HotkeyData hotkeyData)
hotkeyData - hotkey data to processpublic static java.lang.String hotkeyToString(javax.swing.KeyStroke keyStroke)
keyStroke - key stroke to processpublic static java.lang.String hotkeyToString(boolean isCtrl,
boolean isAlt,
boolean isShift,
java.lang.Integer keyCode)
isCtrl - whether hotkey requires CTRL modifier or notisAlt - whether hotkey requires ALT modifier or notisShift - whether hotkey requires SHIFT modifier or notkeyCode - key code for hotkeypublic static boolean isCtrl(java.awt.event.InputEvent event)
event - event to processpublic static boolean isCtrl(int modifiers)
modifiers - modifiers to processpublic static boolean isAlt(java.awt.event.InputEvent event)
event - event to processpublic static boolean isAlt(int modifiers)
modifiers - modifiers to processpublic static boolean isShift(java.awt.event.InputEvent event)
event - event to processpublic static boolean isShift(int modifiers)
modifiers - modifiers to processpublic static HotkeyData getHotkeyData(javax.swing.KeyStroke keyStroke)
keyStroke - key stroke to processpublic static java.awt.Font getDefaultLabelFont()
public static java.awt.FontMetrics getDefaultLabelFontMetrics()
public static javax.swing.JScrollPane getScrollPane(java.awt.Component component)
component - component to processpublic static java.awt.Component findFocusableComponent(java.awt.Container container)
container - container to processpublic static java.util.List<java.awt.Component> findComponentsWithText(java.lang.String text,
java.awt.Component component)
text - text to findcomponent - component or container to look for specified textpublic static java.util.List<java.awt.Component> findComponentsWithText(java.lang.String text,
java.awt.Component component,
java.util.List<java.awt.Component> components)
text - text to findcomponent - component or container to look for specified textcomponents - list of found componentspublic static int indexOf(java.awt.Container parent,
java.awt.Component child)
parent - containerchild - child componentpublic static java.awt.Rectangle getScreenBounds(java.awt.Component component)
component - component to find screen bounds forpublic static java.awt.Rectangle getBoundsOnScreen(java.awt.Component component)
component - component to processpublic static java.awt.Rectangle getBoundsInWindow(java.awt.Component component)
component - component to processpublic static java.awt.Rectangle getRelativeBounds(java.awt.Component component,
java.awt.Component relativeTo)
component - component to processrelativeTo - component relative to which bounds will be returnedpublic static java.awt.Point getRelativeLocation(java.awt.Component component,
java.awt.Component relativeTo)
component - component to processrelativeTo - component relative to which location will be returnedpublic static boolean isSameAncestor(java.awt.Component component1,
java.awt.Component component2)
component1 - first componentcomponent2 - second componentpublic static java.util.Map<java.awt.Component,java.awt.Dimension> getChildPreferredSizes(java.awt.Container container)
container - container to processpublic static void equalizeComponentsSize(java.awt.Component... components)
components - components to modifypublic static void equalizeComponentsSize(java.util.List<java.lang.String> properties,
java.awt.Component... components)
properties - properties to listen for later size updatescomponents - components to modifypublic static void equalizeComponentsSize(java.util.List<? extends java.awt.Component> components)
components - components to modifypublic static void equalizeComponentsSize(java.util.List<java.lang.String> properties,
java.util.List<? extends java.awt.Component> components)
properties - properties to listen for later size updatescomponents - components to modifypublic static void equalizeComponentsWidth(java.awt.Component... components)
components - components to modifypublic static void equalizeComponentsWidth(java.util.List<java.lang.String> properties,
java.awt.Component... components)
properties - properties to listen for later size updatescomponents - components to modifypublic static void equalizeComponentsWidth(java.util.List<? extends java.awt.Component> components)
components - components to modifypublic static void equalizeComponentsWidth(java.util.List<java.lang.String> properties,
java.util.List<? extends java.awt.Component> components)
properties - properties to listen for later size updatescomponents - components to modifypublic static void equalizeComponentsHeight(java.awt.Component... components)
components - components to modifypublic static void equalizeComponentsHeight(java.util.List<java.lang.String> properties,
java.awt.Component... components)
properties - properties to listen for later size updatescomponents - components to modifypublic static void equalizeComponentsHeight(java.util.List<? extends java.awt.Component> components)
components - components to modifypublic static void equalizeComponentsHeight(java.util.List<java.lang.String> properties,
java.util.List<? extends java.awt.Component> components)
properties - properties to listen for later size updatescomponents - components to modifypublic static boolean isEqualOrChild(java.awt.Component component1,
java.awt.Component component2)
component1 - first component to comparecomponent2 - second component to comparepublic static boolean hasFocusOwner(java.awt.Component component)
component - component to processpublic static boolean hasFocusableComponent(java.awt.Container container)
container - container to processpublic static java.lang.String[] getFontNames()
public static java.awt.Font[] getFonts()
public static java.awt.Font[] createFonts(java.lang.String[] fontNames)
fontNames - array of font namespublic static void delayInvokeLater(long delay,
java.lang.Runnable runnable)
delay - delay time in millisecondsrunnable - runnablepublic static void invokeLater(HotkeyRunnable runnable, java.awt.event.KeyEvent e)
runnable - hotkey runnablee - key eventpublic static java.awt.Insets toRTL(java.awt.Insets insets)
insets - insets to convertpublic static void scrollSmoothly(javax.swing.JScrollPane scrollPane,
int xValue,
int yValue)
scrollPane - scroll pane to scroll throughxValue - horizontal scroll bar valueyValue - vertical scroll bar valuepublic static void drawStringUnderlineCharAt(java.awt.Graphics g,
java.lang.String text,
int underlinedIndex,
int x,
int y)
g - graphics contexttext - painted textunderlinedIndex - underlined character indexx - text X coordinatey - text Y coordinatepublic static void drawString(java.awt.Graphics g,
java.lang.String text,
int x,
int y)
g - graphics contexttext - painted textx - text X coordinatey - text Y coordinatepublic static java.util.Map setupTextAntialias(java.awt.Graphics g)
g - graphics contextpublic static java.util.Map setupTextAntialias(java.awt.Graphics2D g2d)
g2d - graphics contextpublic static java.util.Map setupTextAntialias(java.awt.Graphics g,
java.util.Map hints)
g - graphics contexthints - text antialiasing hintspublic static java.util.Map setupTextAntialias(java.awt.Graphics2D g2d,
java.util.Map hints)
g2d - graphics contexthints - text antialiasing hintspublic static void restoreTextAntialias(java.awt.Graphics g,
java.util.Map hints)
g - graphics contexthints - old text antialiasing hintspublic static void restoreTextAntialias(java.awt.Graphics2D g2d,
java.util.Map hints)
g2d - graphics contexthints - old text antialiasing hintspublic static java.awt.FontMetrics getFontMetrics(javax.swing.JComponent c,
java.awt.Graphics g)
This does not necessarily return the FontMetrics from the Graphics.
c - JComponent requesting FontMetrics, may be nullg - Graphics Graphicspublic static java.awt.FontMetrics getFontMetrics(javax.swing.JComponent c,
java.awt.Graphics g,
java.awt.Font font)
This does not necessarily return the FontMetrics from the Graphics.
c - JComponent requesting FontMetrics, may be nullg - Graphics Graphicsfont - Font to get FontMetrics forpublic static void firePropertyChanged(java.awt.Component component,
java.lang.String property,
java.lang.Object oldValue,
java.lang.Object newValue)
firePropertyChange() method is protected and cannot be called w/o using reflection.component - component to fire property change toproperty - changed propertyoldValue - old valuenewValue - new valuepublic static int stringWidth(java.awt.FontMetrics fm,
java.lang.String string)
fm - FontMetrics used to measure the String widthstring - String to get the width ofpublic static java.lang.String clipStringIfNecessary(javax.swing.JComponent c,
java.awt.FontMetrics fm,
java.lang.String string,
int availTextWidth)
c - JComponent that will display the string, may be nullfm - FontMetrics used to measure the String widthstring - String to displayavailTextWidth - Amount of space that the string can be drawn inpublic static java.lang.String clipString(javax.swing.JComponent c,
java.awt.FontMetrics fm,
java.lang.String string,
int availTextWidth)
c - JComponent that will display the string, may be nullfm - FontMetrics used to measure the String widthstring - String to displayavailTextWidth - Amount of space that the string can be drawn inpublic static java.awt.font.FontRenderContext getFontRenderContext(java.awt.Component c,
java.awt.FontMetrics fm)
Uses Component.getFontMetrics to get the FontRenderContext from. see JComponent.getFontMetrics and TextLayoutStrategy.java
c - Componentfm - font metricspublic static int getLeftSideBearing(javax.swing.JComponent c,
java.awt.FontMetrics fm,
java.lang.String string)
c - JComponent that will display the stringfm - FontMetrics used to measure the String widthstring - String to get the left side bearing forpublic static int getLeftSideBearing(javax.swing.JComponent c,
java.awt.FontMetrics fm,
char firstChar)
c - JComponent that will display the stringfm - FontMetrics used to measure the String widthfirstChar - Character to get the left side bearing forpublic static int getRightSideBearing(javax.swing.JComponent c,
java.awt.FontMetrics fm,
java.lang.String string)
c - JComponent that will display the stringfm - FontMetrics used to measure the String widthstring - String to get the right side bearing forpublic static int getRightSideBearing(javax.swing.JComponent c,
java.awt.FontMetrics fm,
char lastChar)
c - JComponent that will display the stringfm - FontMetrics used to measure the String widthlastChar - Character to get the right side bearing for