|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.alee.utils.SwingUtils
public final class SwingUtils
This class provides a set of utilities to work with Swing components, their settings and events.
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
|
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
|
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
|
setBoldFont(C component)
Changes font to bold for the specified component. |
|
static
|
setBoldFont(C component,
boolean apply)
Changes font to bold for the specified component. |
|
static
|
setBorder(C component,
javax.swing.border.Border border)
Sets border for the specified component. |
|
static
|
setBorder(C component,
int border)
Sets an empty border for the specified component. |
|
static
|
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
|
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
|
setFontSize(C component,
int fontSize)
Sets font size of the specified component. |
|
static
|
setFontSizeAndStyle(C component,
int fontSize,
boolean bold,
boolean italic)
Sets font size and style for the specified component. |
|
static
|
setFontSizeAndStyle(C component,
int fontSize,
int style)
Sets font size and style for the specified component. |
|
static
|
setFontStyle(C component,
boolean bold,
boolean italic)
Sets font style for the specified component. |
|
static
|
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
|
setItalicFont(C component)
Changes font to italic for the specified component. |
|
static
|
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
|
setPlainFont(C component)
Changes font to plain for the specified component. |
|
static
|
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 |
---|
public static final java.lang.String HANDLES_ENABLE_STATE
Constructor Detail |
---|
public SwingUtils()
Method Detail |
---|
public static boolean isPreserveBorders(javax.swing.JComponent component)
component
- component to process
public static boolean getHonorUserBorders(javax.swing.JComponent component)
component
- component to process
public static boolean isLafDecorated(java.awt.Component component)
component
- component used to determine window decoration state
public static boolean isLeftMouseButton(java.awt.event.MouseEvent e)
e
- mouse event
public static boolean isMiddleMouseButton(java.awt.event.MouseEvent e)
e
- mouse event
public static boolean isRightMouseButton(java.awt.event.MouseEvent e)
e
- mouse event
public 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 event
public 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 process
public 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 into
public static java.awt.Component getTopComponentAt(java.awt.Component component, int x, int y)
component
- container component to processx
- X coordinatey
- Y coordinate
public static void showAsModal(java.awt.Frame frame, java.awt.Frame owner)
frame
- frame to display as modalowner
- owner framepublic static javax.swing.ButtonGroup groupButtons(java.awt.Container container)
container
- container to process
public static javax.swing.ButtonGroup groupButtons(java.awt.Container container, boolean recursive)
container
- container to processrecursive
- whether to check all subcontainers or not
public static void groupButtons(java.awt.Container container, boolean recursive, javax.swing.ButtonGroup buttonGroup)
container
- container to processrecursive
- whether to check all subcontainers or notbuttonGroup
- button grouppublic static javax.swing.ButtonGroup groupButtons(javax.swing.AbstractButton... buttons)
buttons
- buttons to group
public 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 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 process
public static int maxHeight(java.awt.Component... components)
components
- components to process
public static boolean isHeavyWeightWindow(java.awt.Window window)
window
- window to process
public static <T> T getFirstParent(java.awt.Component component, java.lang.Class<T> parentClass)
T
- parent component class typecomponent
- component to look parent forparentClass
- parent component class
public static java.awt.Window getWindowAncestor(java.awt.Component component)
component
- component to process
public static javax.swing.JRootPane getRootPane(java.awt.Component component)
component
- component to look under
public static java.awt.Container getContentPane(java.awt.Component component)
component
- component to look under
public static javax.swing.JLayeredPane getLayeredPane(java.awt.Component component)
component
- component to look under
public static java.awt.Component getGlassPane(java.awt.Component component)
component
- component to look under
public static <C extends javax.swing.JComponent> C setBorder(C component, int border)
C
- component typecomponent
- component to modifyborder
- component border
public static <C extends javax.swing.JComponent> C setBorder(C component, int top, int left, int bottom, int right)
C
- component typecomponent
- component to modifytop
- component top borderleft
- component left borderbottom
- component bottom borderright
- component right border
public static <C extends javax.swing.JComponent> C setBorder(C component, javax.swing.border.Border border)
C
- component typecomponent
- component to modifyborder
- component border
public static boolean isPlainFont(java.awt.Component component)
component
- component to process
public static <C extends java.awt.Component> C setPlainFont(C component)
C
- component typecomponent
- component to modify
public static <C extends java.awt.Component> C setPlainFont(C component, boolean apply)
C
- component typecomponent
- component to modifyapply
- whether to apply font changes or not
public static boolean isBoldFont(java.awt.Component component)
component
- component to process
public static <C extends java.awt.Component> C setBoldFont(C component)
C
- component typecomponent
- component to modify
public static <C extends java.awt.Component> C setBoldFont(C component, boolean apply)
C
- component typecomponent
- component to modifyapply
- whether to apply font changes or not
public static boolean isItalicFont(java.awt.Component component)
component
- component to process
public static <C extends java.awt.Component> C setItalicFont(C component)
C
- component typecomponent
- component to modify
public static <C extends java.awt.Component> C setItalicFont(C component, boolean apply)
C
- component typecomponent
- component to modifyapply
- whether to apply font changes or not
public static <C extends java.awt.Component> C setFontSize(C component, int fontSize)
C
- component typecomponent
- component to modifyfontSize
- new font size
public static <C extends java.awt.Component> C changeFontSize(C component, int change)
C
- component typecomponent
- component to modifychange
- font size change amount
public static int getFontSize(java.awt.Component component)
component
- component to process
public 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 not
public static <C extends java.awt.Component> C setFontStyle(C component, int style)
C
- component typecomponent
- component to modifystyle
- new style
public 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 not
public static <C extends java.awt.Component> C setFontSizeAndStyle(C component, int fontSize, int style)
C
- component typecomponent
- component to modifyfontSize
- new font sizestyle
- new style
public static <C extends java.awt.Component> C setFontName(C component, java.lang.String fontName)
C
- component typecomponent
- component font namefontName
- new font name
public static java.lang.String getFontName(java.awt.Component component)
component
- component to process
public static java.awt.Dimension copy(java.awt.Dimension dimension)
dimension
- dimension to copy
public static java.awt.Point copy(java.awt.Point point)
point
- point to copy
public static java.awt.Rectangle copy(java.awt.Rectangle rectangle)
rectangle
- rectangle to copy
public static java.awt.Insets copy(java.awt.Insets insets)
insets
- insets to copy
public static java.awt.Color copy(java.awt.Color color)
color
- color to copy
public static java.awt.Rectangle size(java.awt.Component component)
component
- component to process
public static java.awt.Rectangle contentSize(java.awt.Component component)
component
- component to process
public static java.awt.Insets max(java.awt.Insets insets1, java.awt.Insets insets2)
insets1
- first insetsinsets2
- second insets
public static java.awt.Insets min(java.awt.Insets insets1, java.awt.Insets insets2)
insets1
- first insetsinsets2
- second insets
public static java.awt.Dimension max(java.awt.Component component1, java.awt.Component component2)
component1
- first componentcomponent2
- second component
public static java.awt.Dimension max(java.awt.Component... components)
components
- components
public static java.awt.Dimension max(java.awt.Dimension dimension1, java.awt.Dimension dimension2)
dimension1
- first dimensiondimension2
- second dimension
public static java.awt.Dimension min(java.awt.Component component1, java.awt.Component component2)
component1
- first componentcomponent2
- second component
public static java.awt.Dimension min(java.awt.Dimension dimension1, java.awt.Dimension dimension2)
dimension1
- first dimensiondimension2
- second dimension
public 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 childsOnly)
component
- component to modifyopaque
- whether opaque state or notchildsOnly
- 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 childsOnly)
component
- component to modifydoubleBuffered
- whether use double buffering or notchildsOnly
- 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 process
public 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 startFromChilds)
component
- component to modifyenabled
- whether component is enabled or notstartFromChilds
- whether exclude component from changes or notpublic static java.util.List<java.awt.Component> disableRecursively(java.awt.Component component, boolean startFromChilds, boolean excludePanels, java.awt.Component... excluded)
component
- component to disablestartFromChilds
- whether should disable only component childs or notexcludePanels
- whether should exclude panels from disabling or notexcluded
- components to exclude from disabling
public static java.util.List<java.awt.Component> disableRecursively(java.awt.Component component, boolean startFromChilds, boolean excludePanels, java.util.List<java.awt.Component> excluded)
component
- component to disablestartFromChilds
- whether should disable only component childs or notexcludePanels
- whether should exclude panels from disabling or notexcluded
- components to exclude from disabling
public 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 childsOnly)
component
- component to modifyfocusable
- whether component is focusable or notchildsOnly
- 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 childsOnly)
component
- component to modifybg
- new background colorchildsOnly
- 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 childsOnly)
component
- component to modifyforeground
- new foreground colorchildsOnly
- 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 childsOnly)
component
- component to modifyfont
- new fontchildsOnly
- whether exclude component from changes or notpublic static java.awt.image.BufferedImage createComponentSnapshot(java.awt.Component content)
content
- component for snapshot
public static java.awt.image.BufferedImage createComponentSnapshot(java.awt.Component content, int width, int height)
content
- component for snapshotwidth
- snapshot image widthheight
- snapshot image height
public 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 process
public static int getSystemShortcutModifier()
public static java.lang.String hotkeyToString(java.awt.event.KeyEvent keyEvent)
keyEvent
- key event to process
public static java.lang.String hotkeyToString(HotkeyData hotkeyData)
hotkeyData
- hotkey data to process
public static java.lang.String hotkeyToString(javax.swing.KeyStroke keyStroke)
keyStroke
- key stroke to process
public 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 hotkey
public static boolean isCtrl(java.awt.event.InputEvent event)
event
- event to process
public static boolean isCtrl(int modifiers)
modifiers
- modifiers to process
public static boolean isAlt(java.awt.event.InputEvent event)
event
- event to process
public static boolean isAlt(int modifiers)
modifiers
- modifiers to process
public static boolean isShift(java.awt.event.InputEvent event)
event
- event to process
public static boolean isShift(int modifiers)
modifiers
- modifiers to process
public static HotkeyData getHotkeyData(javax.swing.KeyStroke keyStroke)
keyStroke
- key stroke to process
public static java.awt.Font getDefaultLabelFont()
public static javax.swing.JScrollPane getScrollPane(java.awt.Component component)
component
- component to process
public static java.awt.Component findFocusableComponent(java.awt.Container container)
container
- container to process
public 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 text
public 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 components
public static java.awt.Rectangle getBoundsOnScreen(java.awt.Component component)
component
- component to process
public static java.awt.Rectangle getBoundsInWindow(java.awt.Component component)
component
- component to process
public static java.awt.Rectangle getRelativeBounds(java.awt.Component component, java.awt.Component relativeTo)
component
- component to processrelativeTo
- component relative to which bounds will be returned
public static java.awt.Point getRelativeLocation(java.awt.Component component, java.awt.Component relativeTo)
component
- component to processrelativeTo
- component relative to which location will be returned
public static boolean isSameAncestor(java.awt.Component component1, java.awt.Component component2)
component1
- first componentcomponent2
- second component
public static java.util.Map<java.awt.Component,java.awt.Dimension> getChildPreferredSizes(java.awt.Container container)
container
- container to process
public static void equalizeComponentsSize(java.awt.Component... components)
components
- components to modifypublic static void equalizeComponentsWidths(java.awt.Component... components)
components
- components to modifypublic static void equalizeComponentsHeights(java.awt.Component... components)
components
- components to modifypublic static boolean isEqualOrChild(java.awt.Component component1, java.awt.Component component2)
component1
- first component to comparecomponent2
- second component to compare
public static boolean hasFocusOwner(java.awt.Component component)
component
- component to process
public static boolean hasFocusableComponent(java.awt.Container container)
container
- container to process
public 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 names
public static void delayInvokeLater(long delay, java.lang.Runnable runnable)
delay
- delay time in millisecondsrunnable
- runnablepublic static void invokeLater(java.lang.Runnable runnable)
runnable
- runnablepublic static void invokeLater(HotkeyRunnable runnable, java.awt.event.KeyEvent e)
runnable
- hotkey runnablee
- key eventpublic static void invokeAndWait(java.lang.Runnable runnable) throws java.lang.InterruptedException, java.lang.reflect.InvocationTargetException
runnable
- runnable
java.lang.InterruptedException
java.lang.reflect.InvocationTargetException
public static void invokeAndWaitSafely(java.lang.Runnable runnable)
runnable
- runnablepublic static java.awt.Insets toRTL(java.awt.Insets insets)
insets
- insets to convert
public static java.awt.Point getMousePoint(java.awt.Component component)
component
- component to process
public static void scrollSmoothly(javax.swing.JScrollPane scrollPane, int xValue, int yValue)
scrollPane
- scroll pane to scroll throughxValue
- horiontal 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 context
public static java.util.Map setupTextAntialias(java.awt.Graphics2D g2d)
g2d
- graphics context
public static java.util.Map setupTextAntialias(java.awt.Graphics g, java.util.Map hints)
g
- graphics contexthints
- text antialiasing hints
public static java.util.Map setupTextAntialias(java.awt.Graphics2D g2d, java.util.Map hints)
g2d
- graphics contexthints
- text antialiasing hints
public 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)
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)
c
- JComponent requesting FontMetrics, may be nullg
- Graphics Graphicsfont
- Font to get FontMetrics forpublic 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 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |