public final class StaticUIUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
closeWindowByEvent(java.awt.Window window)
Send a
WindowEvent.WINDOW_CLOSING event to the supplied window. |
static int |
correctFrameWidth(int width)
Ensure the frame width is OK.
|
static void |
fitInScreen(java.awt.Component comp) |
static void |
forwardMouseWheelEvent(java.awt.Component target,
java.awt.event.MouseWheelEvent evt) |
static java.awt.Color |
getHighlightColor(java.awt.Color base)
Convenience method for
getHighlightColor(Color, int) using the
default adjustment (10 darker than base). |
static java.awt.Color |
getHighlightColor(java.awt.Color base,
int adjustment)
Calculate a highlight color from a base color, with a given amount of
adjustment.
|
static java.lang.String |
getKeyStrokeText(javax.swing.KeyStroke ks) |
static java.util.List<java.awt.Component> |
listHierarchy(java.awt.Component parent) |
static java.awt.event.FocusListener |
makeCaretAlwaysVisible(javax.swing.text.JTextComponent comp)
Make caret visible even when the
JTextComponent is not editable. |
static javax.swing.Action |
makeCloseAction(java.awt.Window window) |
static void |
makeUndoable(javax.swing.text.JTextComponent comp) |
static void |
persistGeometry(java.awt.Window window,
java.lang.String key) |
static void |
persistGeometry(java.awt.Window window,
java.lang.String key,
java.lang.Runnable extraProcessing) |
static void |
setCaretUpdateEnabled(javax.swing.text.JTextComponent comp,
boolean updateEnabled) |
static void |
setEscapeAction(javax.swing.JDialog dialog,
javax.swing.Action action)
Associate a custom action to be called when the Esc key is pressed.
|
static void |
setEscapeAction(javax.swing.JFrame frame,
javax.swing.Action action)
Associate a custom action to be called when the Esc key is pressed.
|
static void |
setEscapeAction(javax.swing.JRootPane pane,
javax.swing.Action action)
Associate a custom action to be called when the Esc key is pressed.
|
static void |
setEscapeClosable(javax.swing.JDialog dialog)
Make a dialog closeable by pressing the Esc key.
|
static void |
setEscapeClosable(javax.swing.JFrame frame)
Make a dialog closeable by pressing the Esc key.
|
static void |
setHierarchyEnabled(java.awt.Component parent,
boolean isEnabled)
Toggle the enabled property of an entire hierarchy of components.
|
static void |
setWindowIcon(java.awt.Window window) |
static java.lang.String |
truncateToFit(java.lang.String text,
javax.swing.JComponent comp,
int margin)
Truncate the supplied text so that it fits within the width (minus margin)
of the supplied component.
|
static void |
visitHierarchy(java.awt.Component parent,
java.util.function.Consumer<java.awt.Component> consumer) |
static void |
visitHierarchy(java.awt.Component parent,
java.util.function.Predicate<java.awt.Component> filter,
java.util.function.Consumer<java.awt.Component> consumer) |
public static void setEscapeClosable(javax.swing.JDialog dialog)
Window.dispose()
will be called.dialog
- public static void setEscapeClosable(javax.swing.JFrame frame)
Window.dispose()
will be called.frame
- public static javax.swing.Action makeCloseAction(java.awt.Window window)
public static void closeWindowByEvent(java.awt.Window window)
WindowEvent.WINDOW_CLOSING
event to the supplied window.
This mimics closing by clicking the window close button.public static void setEscapeAction(javax.swing.JDialog dialog, javax.swing.Action action)
dialog
- action
- public static void setEscapeAction(javax.swing.JFrame frame, javax.swing.Action action)
frame
- action
- public static void setEscapeAction(javax.swing.JRootPane pane, javax.swing.Action action)
pane
- action
- public static java.lang.String truncateToFit(java.lang.String text, javax.swing.JComponent comp, int margin)
text
- Text to truncatecomp
- Component to fit text intomargin
- Additional space to leave emptypublic static void forwardMouseWheelEvent(java.awt.Component target, java.awt.event.MouseWheelEvent evt)
public static void fitInScreen(java.awt.Component comp)
public static void setCaretUpdateEnabled(javax.swing.text.JTextComponent comp, boolean updateEnabled)
public static java.awt.event.FocusListener makeCaretAlwaysVisible(javax.swing.text.JTextComponent comp)
JTextComponent
is not editable.public static int correctFrameWidth(int width)
width
- Proposed window widthpublic static void setHierarchyEnabled(java.awt.Component parent, boolean isEnabled)
parent
- The parent component, which will also be toggledisEnabled
- Enabled or notpublic static void visitHierarchy(java.awt.Component parent, java.util.function.Consumer<java.awt.Component> consumer)
public static void visitHierarchy(java.awt.Component parent, java.util.function.Predicate<java.awt.Component> filter, java.util.function.Consumer<java.awt.Component> consumer)
public static java.util.List<java.awt.Component> listHierarchy(java.awt.Component parent)
public static void persistGeometry(java.awt.Window window, java.lang.String key)
public static void persistGeometry(java.awt.Window window, java.lang.String key, java.lang.Runnable extraProcessing)
public static void setWindowIcon(java.awt.Window window)
public static java.awt.Color getHighlightColor(java.awt.Color base, int adjustment)
The adjustment is added to each of the base color's RGB values and rebounds from the boundaries [0, 255]. E.g. 250 + 4 -> 254 but 250 + 11 -> 249, and 5 - 4 -> 1 but 5 - 11 -> 6.
public static java.awt.Color getHighlightColor(java.awt.Color base)
getHighlightColor(Color, int)
using the
default adjustment (10 darker than base).public static java.lang.String getKeyStrokeText(javax.swing.KeyStroke ks)
public static void makeUndoable(javax.swing.text.JTextComponent comp)