public class GenericGUIUtilities
extends java.lang.Object
| Constructor and Description |
|---|
GenericGUIUtilities() |
| Modifier and Type | Method and 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 |
isMiddleButton(int modifiers) |
static boolean |
isPopupTrigger(java.awt.event.MouseEvent evt)
Returns if the specified event is the popup trigger event.
|
static boolean |
isRightButton(int modifiers) |
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.
|
public static java.lang.String prettifyMenuLabel(java.lang.String label)
label - the labelpublic static void setAutoMnemonic(javax.swing.AbstractButton button)
button - The button to set the mnemonic for.public static void adjustForScreenBounds(java.awt.Rectangle desired)
public static void requestFocus(java.awt.Window win,
java.awt.Component comp)
win - The windowcomp - The componentpublic static boolean isPopupTrigger(java.awt.event.MouseEvent evt)
evt - The eventpublic static boolean isMiddleButton(int modifiers)
modifiers - The modifiers flag from a mouse eventpublic static boolean isRightButton(int modifiers)
modifiers - The modifiers flag from a mouse eventpublic static java.awt.Rectangle getScreenBounds()
public static void showPopupMenu(javax.swing.JPopupMenu popup,
java.awt.Component comp,
int x,
int y)
popup - The popup menucomp - The component to show it forx - The x co-ordinatey - The y co-ordinatesetComponentPopupMenu
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.public static void showPopupMenu(javax.swing.JPopupMenu popup,
java.awt.Component comp,
int x,
int y,
boolean point)
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.public static boolean isAncestorOf(java.awt.Component comp1,
java.awt.Component comp2)
comp1 - The ancestorcomp2 - The component to checkpublic static javax.swing.JDialog getParentDialog(java.awt.Component c)
c - The componentpublic static void setEnabledRecursively(java.awt.Container c,
boolean enabled)
c - The containerenabled - The enabled state to setpublic static void setButtonContentMargin(javax.swing.AbstractButton button,
java.awt.Insets margin)
button - the button to modifymargin - the new marginpublic static void makeSameSize(java.awt.Component... components)
components - The components to make the same size.public static java.awt.Dimension defaultTableCellSize()
public static int defaultColumnWidth()
public static int defaultRowHeight()