Package org.omegat.util.gui
Class StaticUIUtils
java.lang.Object
org.omegat.util.gui.StaticUIUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcloseWindowByEvent(Window window) Send aWindowEvent.WINDOW_CLOSINGevent to the supplied window.static intcorrectFrameWidth(int width) Ensure the frame width is OK.static voidfitInScreen(Component comp) static voidforwardMouseWheelEvent(Component target, MouseWheelEvent evt) static ColorgetHighlightColor(Color base) Convenience method forgetHighlightColor(Color, int)using the default adjustment (10 darker than base).static ColorgetHighlightColor(Color base, int adjustment) Calculate a highlight color from a base color, with a given amount of adjustment.static Stringstatic booleanisGUI()Whether run on GUI or not.listHierarchy(Component parent) list hierarchy for debug.static FocusListenerMake caret visible even when theJTextComponentis not editable.static voidmakeUndoable(JTextComponent comp) static voidpersistGeometry(Window window, String key) static voidpersistGeometry(Window window, String key, Runnable extraProcessing) static voidrequestVisible(DockableScrollPane scrollPane) Request to show the pane when it is hidden as a tab.static voidsetCaretUpdateEnabled(JTextComponent comp, boolean updateEnabled) static voidsetEscapeAction(JDialog dialog, Action action) Associate a custom action to be called when the Esc key is pressed.static voidsetEscapeAction(JFrame frame, Action action) Associate a custom action to be called when the Esc key is pressed.static voidsetEscapeAction(JRootPane pane, Action action) Associate a custom action to be called when the Esc key is pressed.static voidsetEscapeClosable(JDialog dialog) Make a dialog closeable by pressing the Esc key.static voidsetEscapeClosable(JFrame frame) Make a dialog closeable by pressing the Esc key.static voidsetHierarchyEnabled(Component parent, boolean isEnabled) Toggle the enabled property of an entire hierarchy of components.static voidsetWindowIcon(Window window) static StringtruncateToFit(String text, JComponent comp, int margin) Truncate the supplied text so that it fits within the width (minus margin) of the supplied component.static voidvisitHierarchy(Component parent, Consumer<Component> consumer) static void
-
Method Details
-
setEscapeClosable
Make a dialog closeable by pressing the Esc key.Window.dispose()will be called.- Parameters:
dialog- to configure.
-
setEscapeClosable
Make a dialog closeable by pressing the Esc key.Window.dispose()will be called.- Parameters:
frame- to configure.
-
closeWindowByEvent
Send aWindowEvent.WINDOW_CLOSINGevent to the supplied window. This mimics closing by clicking the window close button. -
setEscapeAction
Associate a custom action to be called when the Esc key is pressed.- Parameters:
dialog- target dialog.action- object to set.
-
setEscapeAction
Associate a custom action to be called when the Esc key is pressed.- Parameters:
frame- target frame.action- object to set.
-
setEscapeAction
Associate a custom action to be called when the Esc key is pressed.- Parameters:
pane- target UI pane.action- object to set.
-
truncateToFit
Truncate the supplied text so that it fits within the width (minus margin) of the supplied component. Truncation is achieved by replacing a chunk from the center of the string with an ellipsis.- Parameters:
text- Text to truncatecomp- Component to fit text intomargin- Additional space to leave empty- Returns:
- A truncated string
-
forwardMouseWheelEvent
-
fitInScreen
-
setCaretUpdateEnabled
-
makeCaretAlwaysVisible
Make caret visible even when theJTextComponentis not editable. -
correctFrameWidth
public static int correctFrameWidth(int width) Ensure the frame width is OK. This is really just a workaround for JDK-8065739 , a Java bug specific to Java 1.8 on OS X whereby a frame too close to the width of the screen will warp to one corner with tiny dimensions.- Parameters:
width- Proposed window width- Returns:
- A safe window width
-
setHierarchyEnabled
Toggle the enabled property of an entire hierarchy of components.- Parameters:
parent- The parent component, which will also be toggledisEnabled- Enabled or not
-
visitHierarchy
-
visitHierarchy
-
listHierarchy
list hierarchy for debug.- Parameters:
parent- component to determine.- Returns:
- list of components.
-
persistGeometry
-
persistGeometry
-
setWindowIcon
-
getHighlightColor
Calculate a highlight color from a base color, with a given amount of 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.
-
getHighlightColor
Convenience method forgetHighlightColor(Color, int)using the default adjustment (10 darker than base). -
getKeyStrokeText
-
makeUndoable
-
requestVisible
Request to show the pane when it is hidden as a tab. -
isGUI
public static boolean isGUI()Whether run on GUI or not.
-