Package org.gjt.sp.util
Class GenericGUIUtilities
- java.lang.Object
-
- org.gjt.sp.util.GenericGUIUtilities
-
public class GenericGUIUtilities extends java.lang.Object
Various GUI utility functions not depending on jEdit, for use in StandaloneTextArea.
-
-
Constructor Summary
Constructors Constructor Description GenericGUIUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
adjustForScreenBounds(java.awt.Rectangle desired)
Gives a rectangle the specified bounds, ensuring it is within the screen bounds.static int
defaultColumnWidth()
Column width for JTable, based on global defaults.static int
defaultRowHeight()
Row height for JTable, based on global defaults.static java.awt.Dimension
defaultTableCellSize()
JTable cell size, based on global defaults.static javax.swing.JDialog
getParentDialog(java.awt.Component c)
Traverses the given component's parent tree looking for an instance of JDialog, and return it.static java.awt.Rectangle
getScreenBounds()
Returns the screen bounds, taking into account multi-screen environments.static boolean
isAncestorOf(java.awt.Component comp1, java.awt.Component comp2)
Returns if the first component is an ancestor of the second by traversing up the component hierarchy.static boolean
isLeftButton(java.awt.event.MouseEvent evt)
static boolean
isMiddleButton(int modifiers)
Deprecated.static boolean
isMiddleButton(java.awt.event.MouseEvent evt)
static boolean
isPopupTrigger(java.awt.event.MouseEvent evt)
Returns if the specified event is the popup trigger event.static boolean
isRightButton(int modifiers)
Deprecated.static boolean
isRightButton(java.awt.event.MouseEvent evt)
static void
makeSameSize(java.awt.Component... components)
Makes components the same size by finding the largest width and height of the given components then setting all components to that width and height.static java.lang.String
prettifyMenuLabel(java.lang.String label)
`Prettifies' a menu item label by removing the `$' sign.static void
requestFocus(java.awt.Window win, java.awt.Component comp)
Focuses on the specified component as soon as the window becomes active.static void
setAutoMnemonic(javax.swing.AbstractButton button)
Sets the mnemonic for the given button using jEdit convention, taking the letter after the dollar.static void
setButtonContentMargin(javax.swing.AbstractButton button, java.awt.Insets margin)
Sets the content margin of a button (for Nimbus L&F).static void
setEnabledRecursively(java.awt.Container c, boolean enabled)
Call setEnabled() recursively on the container and its descendants.static void
showPopupMenu(javax.swing.JPopupMenu popup, java.awt.Component comp, int x, int y)
Shows the specified popup menu, ensuring it is displayed within the bounds of the screen.static void
showPopupMenu(javax.swing.JPopupMenu popup, java.awt.Component comp, int x, int y, boolean point)
Shows the specified popup menu, ensuring it is displayed within the bounds of the screen.
-
-
-
Method Detail
-
prettifyMenuLabel
public static java.lang.String prettifyMenuLabel(java.lang.String label)
`Prettifies' a menu item label by removing the `$' sign. This can be used to process the contents of an action.label property.- Parameters:
label
- the label- Returns:
- a pretty label
- Since:
- jEdit 5.3.1
-
setAutoMnemonic
public static void setAutoMnemonic(javax.swing.AbstractButton button)
Sets the mnemonic for the given button using jEdit convention, taking the letter after the dollar.- Parameters:
button
- The button to set the mnemonic for.- Since:
- jEdit 5.3.1
-
adjustForScreenBounds
public static void adjustForScreenBounds(java.awt.Rectangle desired)
Gives a rectangle the specified bounds, ensuring it is within the screen bounds.- Since:
- jEdit 5.3.1
-
requestFocus
public static void requestFocus(java.awt.Window win, java.awt.Component comp)
Focuses on the specified component as soon as the window becomes active.- Parameters:
win
- The windowcomp
- The component- Since:
- jEdit 5.3.1
-
isPopupTrigger
public static boolean isPopupTrigger(java.awt.event.MouseEvent evt)
Returns if the specified event is the popup trigger event. This implements precisely defined behavior, as opposed to MouseEvent.isPopupTrigger().- Parameters:
evt
- The event- Since:
- jEdit 5.3.1
-
isLeftButton
public static boolean isLeftButton(java.awt.event.MouseEvent evt)
- Parameters:
evt
- A mouse event- Since:
- jEdit 5.6
-
isMiddleButton
@Deprecated public static boolean isMiddleButton(int modifiers)
Deprecated.- Parameters:
modifiers
- The modifiers flag from a mouse event- Since:
- jEdit 5.3.1
-
isMiddleButton
public static boolean isMiddleButton(java.awt.event.MouseEvent evt)
- Parameters:
evt
- A mouse event- Since:
- jEdit 5.6
-
isRightButton
@Deprecated public static boolean isRightButton(int modifiers)
Deprecated.- Parameters:
modifiers
- The modifiers flag from a mouse event- Since:
- jEdit 5.3.1
-
isRightButton
public static boolean isRightButton(java.awt.event.MouseEvent evt)
- Parameters:
evt
- A mouse event- Since:
- jEdit 5.6
-
getScreenBounds
public static java.awt.Rectangle getScreenBounds()
Returns the screen bounds, taking into account multi-screen environments.- Since:
- jEdit 5.3.1
-
showPopupMenu
public static void showPopupMenu(javax.swing.JPopupMenu popup, java.awt.Component comp, int x, int y)
Shows the specified popup menu, ensuring it is displayed within the bounds of the screen.- Parameters:
popup
- The popup menucomp
- The component to show it forx
- The x co-ordinatey
- The y co-ordinate- Since:
- jEdit 4.0pre1, jEdit 5.3.1
- See Also:
setComponentPopupMenu which works better and is simpler to use: you don't have to write the code to show/hide popups in response to mouse events anymore.
-
showPopupMenu
public static void showPopupMenu(javax.swing.JPopupMenu popup, java.awt.Component comp, int x, int y, boolean point)
Shows the specified popup menu, ensuring it is displayed within the bounds of the screen.- Parameters:
popup
- The popup menucomp
- The component to show it forx
- The x co-ordinatey
- The y co-ordinatepoint
- If true, then the popup originates from a single point; otherwise it will originate from the component itself. This affects positioning in the case where the popup does not fit onscreen.- Since:
- jEdit 5.3.1
-
isAncestorOf
public static boolean isAncestorOf(java.awt.Component comp1, java.awt.Component comp2)
Returns if the first component is an ancestor of the second by traversing up the component hierarchy.- Parameters:
comp1
- The ancestorcomp2
- The component to check- Since:
- jEdit 5.3.1
-
getParentDialog
public static javax.swing.JDialog getParentDialog(java.awt.Component c)
Traverses the given component's parent tree looking for an instance of JDialog, and return it. If not found, return null.- Parameters:
c
- The component- Since:
- jEdit 5.3.1
-
setEnabledRecursively
public static void setEnabledRecursively(java.awt.Container c, boolean enabled)
Call setEnabled() recursively on the container and its descendants.- Parameters:
c
- The containerenabled
- The enabled state to set- Since:
- jEdit 5.3.1
-
setButtonContentMargin
public static void setButtonContentMargin(javax.swing.AbstractButton button, java.awt.Insets margin)
Sets the content margin of a button (for Nimbus L&F).- Parameters:
button
- the button to modifymargin
- the new margin- Since:
- jEdit 5.3.1
-
makeSameSize
public static void makeSameSize(java.awt.Component... components)
Makes components the same size by finding the largest width and height of the given components then setting all components to that width and height. This is especially useful for making JButtons the same size.- Parameters:
components
- The components to make the same size.- Since:
- jEdit 5.3.1
-
defaultTableCellSize
public static java.awt.Dimension defaultTableCellSize()
JTable cell size, based on global defaults.- Since:
- jEdit 5.3.1
-
defaultColumnWidth
public static int defaultColumnWidth()
Column width for JTable, based on global defaults.- Since:
- jEdit 5.3.1
-
defaultRowHeight
public static int defaultRowHeight()
Row height for JTable, based on global defaults.- Since:
- jEdit 5.3.1
-
-