public final class SwingUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
HANDLES_ENABLE_STATE
Client property key that identifies that component can handle enabled state changes.
|
static Color |
RENDERING_FIX_COLOR
Constant transparent color used for text rendering fix.
|
Modifier and Type | Method and Description |
---|---|
static void |
changeOrientation(Component component)
Applies opposite component orientation to the specified component and all of its children.
|
static List<Container> |
collectAllContainers(Container container)
Returns list of all sub-containers for this container.
|
static List<Container> |
collectAllContainers(Container container,
List<Container> containers)
Returns list of all sub-containers for this container.
|
static Component |
compositeRequestFocus(Component component)
Performs composite focus request and returns
Component that requested focus. |
static void |
copyOrientation(Component from,
Component to)
Copies component orientation from one component to another.
|
static BufferedImage |
createComponentSnapshot(Component content)
Returns component snapshot image.
|
static BufferedImage |
createComponentSnapshot(Component content,
float opacity)
Returns component snapshot image.
|
static BufferedImage |
createComponentSnapshot(Component content,
int width,
int height)
Returns component snapshot image of specified size.
|
static BufferedImage |
createComponentSnapshot(Component content,
int width,
int height,
float opacity)
Returns component snapshot image of specified size.
|
static Font[] |
createFonts(String[] fontNames)
Returns an array of fonts created using specified array of font names.
|
static Insets |
decrease(Insets insets,
Insets amount)
Returns
insets decreased by amount specified in amount . |
static void |
destroyContainer(Container container)
Destroys container by destroying its children structure and removing all listeners.
|
static List<Component> |
disableRecursively(Component component,
boolean startFromChildren,
boolean excludePanels,
Component... excluded)
Disables component and all of its children recursively.
|
static List<Component> |
disableRecursively(Component component,
boolean startFromChildren,
boolean excludePanels,
List<Component> excluded)
Disables component and all of its children recursively.
|
static void |
enable(List<Component> disabled)
Enables specified components.
|
static void |
equalizeComponentsHeight(Component... components)
Makes all specified component heights equal.
|
static void |
equalizeComponentsHeight(List<? extends Component> components)
Makes all specified component heights equal.
|
static void |
equalizeComponentsHeight(List<String> properties,
Component... components)
Makes all specified component heights equal.
|
static void |
equalizeComponentsHeight(List<String> properties,
List<? extends Component> components)
Makes all specified component heights equal.
|
static void |
equalizeComponentsSize(Component... components)
Makes all specified component sizes equal.
|
static void |
equalizeComponentsSize(List<? extends Component> components)
Makes all specified component sizes equal.
|
static void |
equalizeComponentsSize(List<String> properties,
Component... components)
Makes all specified component sizes equal.
|
static void |
equalizeComponentsSize(List<String> properties,
List<? extends Component> components)
Makes all specified component sizes equal.
|
static void |
equalizeComponentsWidth(Component... components)
Makes all specified component widths equal.
|
static void |
equalizeComponentsWidth(List<? extends Component> components)
Makes all specified component widths equal.
|
static void |
equalizeComponentsWidth(List<String> properties,
Component... components)
Makes all specified component widths equal.
|
static void |
equalizeComponentsWidth(List<String> properties,
List<? extends Component> components)
Makes all specified component widths equal.
|
static List<Component> |
findComponentsWithText(String text,
Component component)
Returns list of all components that visually contains the specified text.
|
static List<Component> |
findComponentsWithText(String text,
Component component,
List<Component> components)
Returns list of all components that visually contains the specified text.
|
static Component |
findFocusableComponent(Container container)
Returns first focusable component found in the container.
|
static void |
firePropertyChanged(Component component,
String property,
Object oldValue,
Object newValue)
Fires painter property change event.
|
static long |
frameRateDelay(int frameRate)
Returns delay in milliseconds for the preferred frame rate.
|
static KeyStroke |
getAccelerator(HotkeyData hotkey)
Returns menu item accelerator for the specified hotkey.
|
static Window |
getActiveWindow()
Returns active application window.
|
static Window |
getAvailableWindow()
Returns first available visible application window.
|
static Map<Component,Dimension> |
getChildPreferredSizes(Container container)
Returns map of container child components preferred sizes.
|
static Container |
getContentPane(Component component)
Returns content pane for the specified component or null if it doesn't exist.
|
static Font |
getDefaultLabelFont()
Returns default label font.
|
static FontMetrics |
getDefaultLabelFontMetrics()
Returns default label font metrics.
|
static <C extends Component> |
getFirst(Container container,
Class<C> componentClass)
Returns first component placed in the specified container which is instance of specified class type or null if none found.
|
static <C extends Component> |
getFirst(Container container,
Class<C> componentClass,
boolean recursive)
Returns first component placed in the specified container which is instance of specified class type or null if none found.
|
static <C extends Container> |
getFirstParent(Component component,
Class<C> parentClass)
Returns first parent which is instance of specified class type or null if none found.
|
static <C extends JComponent> |
getFirstParentSupportingDrop(Component component)
Returns first parent component which supports drag and drop actions.
|
static int |
getFocusAcceleratorKeyMask()
Returns focus accelerator key mask.
|
static FontMetrics |
getFontMetrics(JComponent component,
Graphics g)
Returns the FontMetrics for the current Font of the passed in Graphics.
|
static FontMetrics |
getFontMetrics(JComponent component,
Graphics g,
Font font)
Returns the FontMetrics for the specified Font.
|
static String[] |
getFontNames()
Returns system font names array.
|
static Font[] |
getFonts()
Returns system fonts array.
|
static Component |
getGlassPane(Component component)
Returns glass pane for the specified component or null if it doesn't exist.
|
static boolean |
getHonorUserBorders(JComponent component)
Returns whether UI delegate should honor a user-specified border on this component or not.
|
static HotkeyData |
getHotkeyData(KeyStroke keyStroke)
Returns hotkey data extracted from the specified key stroke.
|
static JLayeredPane |
getLayeredPane(Component component)
Returns layered pane for the specified component or null if it doesn't exist.
|
static int |
getMnemonicIndex(String text,
int mnemonic)
Returns index of the first occurrence of
mnemonic within string text . |
static JScrollPane |
getScrollPane(Component component)
|
static int |
getSystemShortcutModifier()
Returns system shortcut modifier.
|
static ButtonGroup |
groupButtons(AbstractButton... buttons)
Groups specified buttons and returns created button group.
|
static void |
groupButtons(ButtonGroup buttonGroup,
AbstractButton... buttons)
Groups buttons in the specified button group.
|
static ButtonGroup |
groupButtons(Container container)
Groups all buttons inside this container and returns created button group.
|
static ButtonGroup |
groupButtons(Container container,
boolean recursive)
Groups all buttons inside this container and all sub-containers if requested and returns created button group.
|
static void |
groupButtons(Container container,
boolean recursive,
ButtonGroup buttonGroup)
Groups all buttons inside this container and all sub-containers if requested and returns created button group.
|
static boolean |
hasFocusableComponent(Container container)
Returns whether at least one of child components within the specified container is focusable or not.
|
static boolean |
hasFocusOwner(Component component)
Returns whether component or any of its children has focus or not.
|
static String |
hotkeyToString(boolean isCtrl,
boolean isAlt,
boolean isShift,
Integer keyCode)
Returns readable form for specified hotkey.
|
static String |
hotkeyToString(HotkeyData hotkeyData)
Returns readable form of specified hotkey data.
|
static String |
hotkeyToString(KeyEvent keyEvent)
Returns readable form of hotkey triggered by specified key event.
|
static String |
hotkeyToString(KeyStroke keyStroke)
Returns readable form of specified key stroke.
|
static Dimension |
increase(Dimension dimension,
Insets amount)
Returns
dimension increased by amount specified in amount . |
static Insets |
increase(Insets insets,
Insets amount)
Returns
insets increased by amount specified in amount . |
static int |
indexOf(Container container,
Component child)
Returns component index within the specified parent container.
|
static boolean |
isAlt(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 |
isCtrl(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 |
isDoubleClick(MouseEvent e)
Returns whether or not event represents most common double click event.
|
static boolean |
isDoubleClick(MouseEvent e,
boolean repeatable)
Returns whether or not event represents most common double click event.
|
static boolean |
isEmpty(Insets insets)
Returns whether or not provided insets are empty.
|
static boolean |
isEmpty(JTextComponent component)
Returns whether or not specified
JTextComponent content is empty. |
static boolean |
isEqualOrChild(Component component,
Component child)
Returns whether the first component or any of its children are equal to second component or not.
|
static boolean |
isHandlesEnableState(Component component)
Returns whether or not
HANDLES_ENABLE_STATE client property is set to true in the specified Component . |
static boolean |
isHeavyWeightWindow(Window window)
Returns whether specified window is a HeavyWeightWindow or not.
|
static boolean |
isLeftMouseButton(MouseEvent e)
Returns whether event involves left mouse button or not.
|
static boolean |
isMiddleMouseButton(MouseEvent e)
Returns whether event involves middle mouse button or not.
|
static boolean |
isOpaque(Component component)
Returns whether or not specified component is opaque.
|
static boolean |
isPopupTrigger(MouseEvent e)
Returns whether the specific mouse events triggers popup menu or not.
|
static boolean |
isPreserveBorders(JComponent component)
Returns whether UI delegate should preserve current border on this component or not.
|
static boolean |
isRightMouseButton(MouseEvent e)
Returns whether event involves right mouse button or not.
|
static boolean |
isShift(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(InputEvent event)
Returns whether specified event contains shortcut modifier or not.
|
static boolean |
isUIResource(Object value)
Returns whether or not specified value is a UI resource.
|
static Dimension |
max(Dimension dimension1,
Dimension dimension2)
Returns maximum dimension combined from specified ones.
|
static Insets |
max(Insets insets1,
Insets insets2)
Returns maximum insets combined from the specified ones.
|
static Dimension |
maxNonNull(Dimension dimension1,
Dimension dimension2)
Returns maximum dimension combined from specified ones.
|
static Insets |
maxNonNull(Insets insets1,
Insets insets2)
Returns maximum insets combined from the specified ones.
|
static int |
maxPreferredHeight(Component... components)
Returns maximum component height.
|
static Dimension |
maxPreferredSize(Component... components)
Returns maximum dimension combined from specified components dimensions.
|
static Dimension |
maxPreferredSize(Component component1,
Component component2)
Returns maximum dimension combined from specified components dimensions.
|
static int |
maxPreferredWidth(Component... components)
Returns maximum component width.
|
static Dimension |
min(Dimension dimension1,
Dimension dimension2)
Returns minimum dimension combined from specified ones.
|
static Insets |
min(Insets insets1,
Insets insets2)
Returns minimum insets combined from the specified ones.
|
static Dimension |
minNonNull(Dimension dimension1,
Dimension dimension2)
Returns minimum dimension combined from specified ones.
|
static Insets |
minNonNull(Insets insets1,
Insets insets2)
Returns minimum insets combined from the specified ones.
|
static Dimension |
minPreferredSize(Component... components)
Returns maximum dimension combined from specified components dimensions.
|
static Dimension |
minPreferredSize(Component component1,
Component component2)
Returns minimum dimension combined from specified components dimensions.
|
static Rectangle |
moveBy(Rectangle rectangle,
Point point)
|
static void |
packColumnWidth(JTable table,
int col)
Packs table column at the specified index to its preferred width.
|
static void |
packColumnWidth(JTable table,
int col,
int margin)
Packs table column at the specified index to its preferred width.
|
static void |
packColumnWidths(JTable table)
Packs all table columns to their preferred width.
|
static void |
packColumnWidths(JTable table,
int margin)
Packs all table columns to their preferred width.
|
static void |
packRowHeights(JTable table)
Packs all table rows to their preferred height.
|
static void |
removeFromParent(Component component,
boolean update)
Removes
Component from its current parent if it has one. |
static void |
removeHandlesEnableStateMark(JComponent component)
Removes
HANDLES_ENABLE_STATE client property from the specified JComponent . |
static void |
restoreTextAntialias(Graphics2D g2d,
Map hints)
Restores text antialiasing hints into specified graphics context
|
static void |
restoreTextAntialias(Graphics g,
Map hints)
Restores text antialiasing hints into specified graphics context
|
static void |
setBackgroundRecursively(Component component,
Color bg)
Sets background color of component and all of its children.
|
static void |
setBackgroundRecursively(Component component,
Color bg,
boolean childrenOnly)
Sets background color of component and all of its children.
|
static void |
setDoubleBufferedRecursively(Component component,
boolean doubleBuffered)
Sets double buffered state of component and all of its children.
|
static void |
setDoubleBufferedRecursively(Component component,
boolean doubleBuffered,
boolean childrenOnly)
Sets double buffered state of component and all of its children.
|
static void |
setEnabledRecursively(Component component,
boolean enabled)
Sets enabled state of component and all of its children.
|
static void |
setEnabledRecursively(Component component,
boolean enabled,
boolean startFromChildren)
Sets enabled state of component and all of its children.
|
static void |
setFocusableRecursively(JComponent component,
boolean focusable)
Sets focusable state of component and all of its children.
|
static void |
setFocusableRecursively(JComponent component,
boolean focusable,
boolean childrenOnly)
Sets focusable state of component and all of its children.
|
static void |
setFontRecursively(JComponent component,
Font font)
Sets font of component and all of its children.
|
static void |
setFontRecursively(JComponent component,
Font font,
boolean childrenOnly)
Sets font of component and all of its children.
|
static void |
setForegroundRecursively(JComponent component,
Color foreground)
Sets foreground color of component and all of its children.
|
static void |
setForegroundRecursively(JComponent component,
Color foreground,
boolean childrenOnly)
Sets foreground color of component and all of its children.
|
static void |
setHandlesEnableStateMark(JComponent component)
Adds
HANDLES_ENABLE_STATE client property into the specified JComponent . |
static void |
setHonorUserBorders(JComponent component,
boolean honor)
Sets whether UI delegate should honor a user-specified border on this component or not.
|
static void |
setOpaqueRecursively(Component component,
boolean opaque)
Sets opaque state of component and all of its children.
|
static void |
setOpaqueRecursively(Component component,
boolean opaque,
boolean childrenOnly)
Sets opaque state of component and all of its children.
|
static Map |
setupTextAntialias(Graphics g)
Installs text antialiasing hints into specified graphics context.
|
static Map |
setupTextAntialias(Graphics2D g2d)
Installs text antialiasing hints into specified graphics context.
|
static Map |
setupTextAntialias(Graphics2D g2d,
TextRasterization rasterization)
Installs text antialiasing hints into specified graphics context.
|
static Map |
setupTextAntialias(Graphics g,
TextRasterization rasterization)
Installs text antialiasing hints into specified graphics context.
|
static Dimension |
shrink(Dimension dimension,
Insets insets)
Returns dimension shrunk by provided insets.
|
static Rectangle |
shrink(Rectangle rectangle,
Insets insets)
|
static Dimension |
stretch(Dimension dimension,
Insets insets)
Returns dimension stretched by provided insets.
|
static int |
stringWidth(FontMetrics fontMetrics,
String string)
Returns the width of the passed in String.
|
static Insets |
toRTL(Insets insets)
Returns insets converted into RTL orientation.
|
static void |
update(Component component)
Performs full component view update.
|
static void |
updateGlobalOrientation(ComponentOrientation orientation)
Sets specified component orientation for all existing components.
|
@NotNull public static final String HANDLES_ENABLE_STATE
public static boolean isOpaque(@NotNull Component component)
component
- component to check opacity fortrue
if specified component is opaque, false
otherwisepublic static void update(Component component)
component
- component to updatepublic static void removeFromParent(@Nullable Component component, boolean update)
Component
from its current parent if it has one.public static boolean isEmpty(@NotNull JTextComponent component)
JTextComponent
content is empty.component
- JTextComponent
to checktrue
if specified JTextComponent
content is empty, false
otherwisepublic static boolean isEmpty(@Nullable Insets insets)
null
insets are considered as empty as well.insets
- insets to processpublic static boolean isPreserveBorders(@NotNull JComponent component)
component
- component to processpublic static boolean isUIResource(@Nullable Object value)
value
- value Object
to processtrue
if specified value is a UI resource, false
otherwisepublic static boolean getHonorUserBorders(@NotNull JComponent component)
component
- component to processpublic static void setHonorUserBorders(@NotNull 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(@NotNull MouseEvent e)
e
- mouse eventpublic static boolean isMiddleMouseButton(@NotNull MouseEvent e)
e
- mouse eventpublic static boolean isRightMouseButton(@NotNull MouseEvent e)
e
- mouse eventpublic static boolean isDoubleClick(@NotNull MouseEvent e)
e
- mouse eventpublic static boolean isDoubleClick(@NotNull MouseEvent e, boolean repeatable)
e
- mouse eventrepeatable
- whether or not double click condition can be accepted more than once within a single click sequencepublic static void packRowHeights(@NotNull JTable table)
table
- table to processpublic static void packColumnWidths(@NotNull JTable table)
table
- table to processpublic static void packColumnWidths(@NotNull JTable table, int margin)
table
- table to processmargin
- column side marginpublic static void packColumnWidth(@NotNull JTable table, int col)
table
- table to processcol
- column indexpublic static void packColumnWidth(@NotNull JTable table, int col, int margin)
table
- table to processcol
- column indexmargin
- column side marginpublic static boolean isPopupTrigger(@NotNull MouseEvent e)
e
- mouse eventpublic static void destroyContainer(@NotNull Container container)
container
- container to destroy@NotNull public static List<Container> collectAllContainers(@NotNull Container container)
container
- container to process@NotNull public static List<Container> collectAllContainers(@NotNull Container container, @NotNull List<Container> containers)
container
- container to processcontainers
- list to collect sub-containers into@NotNull public static ButtonGroup groupButtons(@NotNull Container container)
container
- container to process@NotNull public static ButtonGroup groupButtons(@NotNull Container container, boolean recursive)
container
- container to processrecursive
- whether to check all sub-containers or notpublic static void groupButtons(@NotNull Container container, boolean recursive, @NotNull ButtonGroup buttonGroup)
container
- container to processrecursive
- whether to check all sub-containers or notbuttonGroup
- button group@NotNull public static ButtonGroup groupButtons(@NotNull AbstractButton... buttons)
buttons
- buttons to grouppublic static void groupButtons(@NotNull ButtonGroup buttonGroup, @NotNull AbstractButton... buttons)
buttonGroup
- button groupbuttons
- buttons to grouppublic static void copyOrientation(@NotNull Component from, @NotNull Component to)
from
- component to copy orientation fromto
- component to copy orientation intopublic static void changeOrientation(@NotNull Component component)
component
- component to change orientation forpublic static void updateGlobalOrientation(@NotNull ComponentOrientation orientation)
orientation
- component orientation to setpublic static boolean isHeavyWeightWindow(@Nullable Window window)
window
- window to process@Nullable public static <C extends Container> C getFirstParent(@NotNull Component component, @NotNull Class<C> parentClass)
C
- parent component class typecomponent
- component to look parent forparentClass
- parent component class@Nullable public static <C extends Component> C getFirst(@NotNull Container container, @NotNull Class<C> componentClass)
C
- component class typecontainer
- container to look for component incomponentClass
- component class@Nullable public static <C extends Component> C getFirst(@NotNull Container container, @NotNull Class<C> componentClass, boolean recursive)
C
- component class typecontainer
- container to look for component incomponentClass
- component classrecursive
- whether to check all sub-containers or not@Nullable public static <C extends JComponent> C getFirstParentSupportingDrop(@NotNull Component component)
C
- parent supporting drop component class typecomponent
- component to look parent supporting drop for@Nullable public static Window getAvailableWindow()
@Nullable public static Container getContentPane(@NotNull Component component)
component
- component to look under@Nullable public static JLayeredPane getLayeredPane(@NotNull Component component)
component
- component to look under@Nullable public static Component getGlassPane(@NotNull Component component)
component
- component to look under@NotNull public static Insets increase(@NotNull Insets insets, @Nullable Insets amount)
insets
increased by amount specified in amount
.insets
- insets to increasedamount
- increase amountinsets
increased by amount specified in amount
@NotNull public static Dimension increase(@NotNull Dimension dimension, @Nullable Insets amount)
dimension
increased by amount specified in amount
.dimension
- dimension to increasedamount
- increase amountdimension
increased by amount specified in amount
@NotNull public static Insets decrease(@NotNull Insets insets, @Nullable Insets amount)
insets
decreased by amount specified in amount
.insets
- insets to decreasedamount
- decrease amountinsets
decreased by amount specified in amount
@Nullable public static Insets max(@Nullable Insets insets1, @Nullable Insets insets2)
insets1
- first insetsinsets2
- second insets@NotNull public static Insets maxNonNull(@NotNull Insets insets1, @NotNull Insets insets2)
insets1
- first insetsinsets2
- second insets@Nullable public static Insets min(@Nullable Insets insets1, @Nullable Insets insets2)
insets1
- first insetsinsets2
- second insets@NotNull public static Insets minNonNull(@NotNull Insets insets1, @NotNull Insets insets2)
insets1
- first insetsinsets2
- second insets@NotNull public static Dimension maxPreferredSize(@NotNull Component component1, @NotNull Component component2)
component1
- first componentcomponent2
- second component@NotNull public static Dimension maxPreferredSize(@NotNull Component... components)
components
- componentspublic static int maxPreferredWidth(@NotNull Component... components)
components
- components to processpublic static int maxPreferredHeight(@NotNull Component... components)
components
- components to process@Nullable public static Dimension max(@Nullable Dimension dimension1, @Nullable Dimension dimension2)
dimension1
- first dimensiondimension2
- second dimension@NotNull public static Dimension maxNonNull(@Nullable Dimension dimension1, @Nullable Dimension dimension2)
dimension1
- first dimensiondimension2
- second dimension@NotNull public static Dimension minPreferredSize(@NotNull Component component1, @NotNull Component component2)
component1
- first componentcomponent2
- second component@NotNull public static Dimension minPreferredSize(@NotNull Component... components)
components
- components@Nullable public static Dimension min(@Nullable Dimension dimension1, @Nullable Dimension dimension2)
dimension1
- first dimensiondimension2
- second dimension@NotNull public static Dimension minNonNull(@NotNull Dimension dimension1, @NotNull Dimension dimension2)
dimension1
- first dimensiondimension2
- second dimension@NotNull public static Rectangle shrink(@NotNull Rectangle rectangle, @Nullable Insets insets)
@NotNull public static Dimension shrink(@NotNull Dimension dimension, @Nullable Insets insets)
dimension
- dimension to shrinkinsets
- insets used to shrink dimension@NotNull public static Dimension stretch(@NotNull Dimension dimension, @Nullable Insets insets)
dimension
- dimension to stretchinsets
- insets used to stretch dimensionpublic static void setOpaqueRecursively(@NotNull Component component, boolean opaque)
component
- component to modifyopaque
- whether opaque state or notpublic static void setOpaqueRecursively(@NotNull 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(@NotNull Component component, boolean doubleBuffered)
component
- component to modifydoubleBuffered
- whether use double buffering or notpublic static void setDoubleBufferedRecursively(@NotNull 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(@NotNull JComponent component)
HANDLES_ENABLE_STATE
client property into the specified JComponent
.component
- JComponent
to set client property forpublic static void removeHandlesEnableStateMark(@NotNull JComponent component)
HANDLES_ENABLE_STATE
client property from the specified JComponent
.component
- JComponent
to remove client property frompublic static boolean isHandlesEnableState(@NotNull Component component)
HANDLES_ENABLE_STATE
client property is set to true
in the specified Component
.component
- Component
to check client property intrue
if HANDLES_ENABLE_STATE
client property is set to true
, false
otherwisepublic static void setEnabledRecursively(@NotNull Component component, boolean enabled)
component
- component to modifyenabled
- whether component is enabled or notpublic static void setEnabledRecursively(@NotNull Component component, boolean enabled, boolean startFromChildren)
component
- component to modifyenabled
- whether component is enabled or notstartFromChildren
- whether exclude component from changes or not@NotNull public static List<Component> disableRecursively(@NotNull Component component, boolean startFromChildren, boolean excludePanels, @NotNull 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 disabling@NotNull public static List<Component> disableRecursively(@NotNull Component component, boolean startFromChildren, boolean excludePanels, @NotNull List<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(@NotNull List<Component> disabled)
disabled
- disabled components listpublic static void setFocusableRecursively(@NotNull JComponent component, boolean focusable)
component
- component to modifyfocusable
- whether component is focusable or notpublic static void setFocusableRecursively(@NotNull 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(@NotNull Component component, Color bg)
component
- component to modifybg
- new background colorpublic static void setBackgroundRecursively(@NotNull Component component, Color bg, boolean childrenOnly)
component
- component to modifybg
- new background colorchildrenOnly
- whether exclude component from changes or notpublic static void setForegroundRecursively(@NotNull JComponent component, @Nullable Color foreground)
component
- component to modifyforeground
- new foreground colorpublic static void setForegroundRecursively(@NotNull JComponent component, @Nullable Color foreground, boolean childrenOnly)
component
- component to modifyforeground
- new foreground colorchildrenOnly
- whether exclude component from changes or notpublic static void setFontRecursively(@NotNull JComponent component, @Nullable Font font)
component
- component to modifyfont
- new fontpublic static void setFontRecursively(@NotNull JComponent component, @Nullable Font font, boolean childrenOnly)
component
- component to modifyfont
- new fontchildrenOnly
- whether exclude component from changes or not@NotNull public static BufferedImage createComponentSnapshot(@NotNull Component content)
content
- component for snapshot@NotNull public static BufferedImage createComponentSnapshot(@NotNull Component content, float opacity)
content
- component for snapshotopacity
- snapshot opacity@NotNull public static BufferedImage createComponentSnapshot(@NotNull Component content, int width, int height)
content
- component for snapshotwidth
- snapshot image widthheight
- snapshot image height@NotNull public static BufferedImage createComponentSnapshot(@NotNull Component content, int width, int height, float opacity)
content
- component for snapshotwidth
- snapshot image widthheight
- snapshot image heightopacity
- snapshot opacity@Nullable public static KeyStroke getAccelerator(@Nullable HotkeyData hotkey)
hotkey
- hotkey to provide accelerator based onpublic static int getFocusAcceleratorKeyMask()
public static int getMnemonicIndex(String text, int mnemonic)
mnemonic
within string text
.
Matching algorithm is not case-sensitive.text
- text to search through, may be null
mnemonic
- mnemonic to find the character for@Nullable public static Window getActiveWindow()
public static boolean isShortcut(@NotNull InputEvent event)
event
- event to processpublic static int getSystemShortcutModifier()
@NotNull public static String hotkeyToString(@NotNull KeyEvent keyEvent)
keyEvent
- key event to process@NotNull public static String hotkeyToString(@NotNull HotkeyData hotkeyData)
hotkeyData
- hotkey data to process@NotNull public static String hotkeyToString(@NotNull KeyStroke keyStroke)
keyStroke
- key stroke to process@NotNull public static String hotkeyToString(boolean isCtrl, boolean isAlt, boolean isShift, @Nullable 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(@NotNull InputEvent event)
event
- event to processpublic static boolean isCtrl(int modifiers)
modifiers
- modifiers to processpublic static boolean isAlt(@NotNull InputEvent event)
event
- event to processpublic static boolean isAlt(int modifiers)
modifiers
- modifiers to processpublic static boolean isShift(@NotNull InputEvent event)
event
- event to processpublic static boolean isShift(int modifiers)
modifiers
- modifiers to process@NotNull public static HotkeyData getHotkeyData(@NotNull KeyStroke keyStroke)
keyStroke
- key stroke to process@NotNull public static Font getDefaultLabelFont()
@NotNull public static FontMetrics getDefaultLabelFontMetrics()
@Nullable public static JScrollPane getScrollPane(@Nullable Component component)
component
- Component
to processJSplitPane
for the specified Component
if it is directly added into one, null
otherwise@Nullable public static Component compositeRequestFocus(@NotNull Component component)
Component
that requested focus.@Nullable public static Component findFocusableComponent(@NotNull Container container)
container
- container to process@NotNull public static List<Component> findComponentsWithText(@Nullable String text, @Nullable Component component)
text
- text to findcomponent
- component or container to look for specified text@NotNull public static List<Component> findComponentsWithText(@Nullable String text, @Nullable Component component, @NotNull List<Component> components)
text
- text to findcomponent
- component or container to look for specified textcomponents
- list of found componentspublic static int indexOf(@NotNull Container container, @Nullable Component child)
container
- containerchild
- child component@NotNull public static Map<Component,Dimension> getChildPreferredSizes(@NotNull Container container)
container
- container to processpublic static void equalizeComponentsSize(@NotNull Component... components)
components
- components to modifypublic static void equalizeComponentsSize(@NotNull List<String> properties, @NotNull Component... components)
properties
- properties to listen for later size updatescomponents
- components to modifypublic static void equalizeComponentsSize(@NotNull List<? extends Component> components)
components
- components to modifypublic static void equalizeComponentsSize(@NotNull List<String> properties, @NotNull List<? extends Component> components)
properties
- properties to listen for later size updatescomponents
- components to modifypublic static void equalizeComponentsWidth(@NotNull Component... components)
components
- components to modifypublic static void equalizeComponentsWidth(@NotNull List<String> properties, @NotNull Component... components)
properties
- properties to listen for later size updatescomponents
- components to modifypublic static void equalizeComponentsWidth(@NotNull List<? extends Component> components)
components
- components to modifypublic static void equalizeComponentsWidth(@NotNull List<String> properties, @NotNull List<? extends Component> components)
properties
- properties to listen for later size updatescomponents
- components to modifypublic static void equalizeComponentsHeight(@NotNull Component... components)
components
- components to modifypublic static void equalizeComponentsHeight(@NotNull List<String> properties, @NotNull Component... components)
properties
- properties to listen for later size updatescomponents
- components to modifypublic static void equalizeComponentsHeight(@NotNull List<? extends Component> components)
components
- components to modifypublic static void equalizeComponentsHeight(@NotNull List<String> properties, @NotNull List<? extends Component> components)
properties
- properties to listen for later size updatescomponents
- components to modifypublic static boolean isEqualOrChild(@Nullable Component component, @Nullable Component child)
component
- first component to comparechild
- second component to comparetrue
if the first component or any of its children are equal to second component, false
otherwisepublic static boolean hasFocusOwner(@Nullable Component component)
component
- component to processpublic static boolean hasFocusableComponent(@NotNull Container container)
container
- container to process@NotNull public static String[] getFontNames()
@NotNull public static Font[] getFonts()
@NotNull public static Font[] createFonts(@NotNull String[] fontNames)
fontNames
- array of font names@NotNull public static Insets toRTL(@NotNull Insets insets)
insets
- insets to convertpublic static Map setupTextAntialias(@NotNull Graphics g)
g
- graphics contextpublic static Map setupTextAntialias(@NotNull Graphics2D g2d)
g2d
- graphics contextpublic static Map setupTextAntialias(@NotNull Graphics g, @NotNull TextRasterization rasterization)
g
- graphics contextrasterization
- text rasterization optionpublic static Map setupTextAntialias(@NotNull Graphics2D g2d, @NotNull TextRasterization rasterization)
g2d
- graphics contextrasterization
- text rasterization optionpublic static void restoreTextAntialias(@NotNull Graphics g, @Nullable Map hints)
g
- graphics contexthints
- old text antialiasing hintspublic static void restoreTextAntialias(@NotNull Graphics2D g2d, @Nullable Map hints)
g2d
- graphics contexthints
- old text antialiasing hints@NotNull public static FontMetrics getFontMetrics(@Nullable JComponent component, @NotNull Graphics g)
This does not necessarily return the FontMetrics from the Graphics.
component
- JComponent requesting FontMetrics, may be nullg
- Graphics Graphics@NotNull public static FontMetrics getFontMetrics(@Nullable JComponent component, @NotNull Graphics g, @NotNull Font font)
This does not necessarily return the FontMetrics from the Graphics.
component
- JComponent requesting FontMetrics, may be nullg
- Graphics Graphicsfont
- Font to get FontMetrics forpublic static void firePropertyChanged(@NotNull Component component, @NotNull String property, @Nullable Object oldValue, @Nullable 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 long frameRateDelay(int frameRate)
frameRate
- frame rate per second (FPS)public static int stringWidth(@NotNull FontMetrics fontMetrics, @Nullable String string)
fontMetrics
- FontMetrics used to measure the String widthstring
- String to get the width ofCopyright © 2020. All rights reserved.