public class GUIUtilities
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ACCELERATOR_KEY
JDK1.2 doesn't have this string defined in javax.swing.Action.
|
static java.lang.String |
LARGE_ICON
This key is used in an action to specify an icon used in toolbars.
|
static java.lang.String |
MNEMONIC_KEY
JDK1.2 doesn't have this string defined in javax.swing.Action.
|
static java.lang.String |
ROLLOVER_ICON
This key is used in an action to specify a rollover icon
used in toolbars.
|
static java.lang.String |
ROLLOVER_SELECTED_ICON
This key is used in an action to specify a rollover selected icon
used in toolbars.
|
static java.lang.String |
SELECTED_ICON
This key is used in an action to specify a selected icon
used in toolbars.
|
Constructor and Description |
---|
GUIUtilities() |
Modifier and Type | Method and Description |
---|---|
static void |
addHotKey(javax.swing.JComponent pane,
javax.swing.Action action)
Add a quick keystroke on the given pane for the given action.
|
static void |
addHotKey(javax.swing.JComponent pane,
javax.swing.Action action,
javax.swing.KeyStroke key)
Add a quick keystroke on the given pane for the given action.
|
static void |
addIcons(javax.swing.Action action,
java.lang.String[][] iconRoles)
Add icons to an action.
|
static javax.swing.JMenuItem |
addMenuItem(javax.swing.JMenu menu,
javax.swing.Action action)
Add an action to a menu and return the menu item created.
|
static javax.swing.JMenuItem |
addMenuItem(javax.swing.JMenu menu,
javax.swing.Action action,
int mnemonic,
java.lang.String tooltip)
Add an action to a menu and return the menu item created.
|
static javax.swing.JMenuItem |
addMenuItem(javax.swing.JMenu menu,
java.lang.String label,
javax.swing.Action action,
int mnemonic,
java.lang.String tooltip,
boolean isEnabled)
Add an action to a menu and return the menu item created.
|
static javax.swing.JButton |
addToolBarButton(javax.swing.JToolBar toolbar,
javax.swing.Action action)
Add the action to the given toolbar.
|
static javax.swing.JButton |
addToolBarButton(javax.swing.JToolBar toolbar,
javax.swing.Action action,
java.lang.String tooltip,
javax.swing.Icon icon)
Add an action to the toolbar.
|
static javax.swing.JButton |
addToolBarButton(javax.swing.JToolBar toolbar,
javax.swing.Action action,
java.lang.String tooltip,
javax.swing.Icon icon,
boolean isEnabled)
Add an action to the toolbar.
|
static javax.swing.JButton |
addToolBarButton(javax.swing.JToolBar toolbar,
javax.swing.Action action,
java.lang.String tooltip,
javax.swing.Icon icon,
java.lang.String lbl)
Add an action to the toolbar.
|
static javax.swing.JButton |
addToolBarButton(javax.swing.JToolBar toolbar,
javax.swing.Action action,
java.lang.String tooltip,
javax.swing.Icon icon,
java.lang.String lbl,
boolean isEnabled)
Add an action to the toolbar.
|
static javax.swing.JButton |
addToolBarButton(javax.swing.JToolBar toolbar,
javax.swing.Action action,
java.lang.String tooltip,
java.lang.String lbl)
Add an action to the toolbar.
|
static java.lang.String |
ellipsis(java.lang.String string,
int length)
Return a string that contains the original string, limited to the
given number of characters.
|
static java.lang.String |
getFileExtension(java.io.File file)
Get the extension of a file.
|
static java.lang.String |
keyStrokeToString(javax.swing.KeyStroke key)
Return a good string representation of the given keystroke, since
the toString method returns more garbage than we want to see in a
user interface.
|
static void |
showException(java.awt.Component parent,
java.lang.Exception e,
java.lang.String info)
Display an exception in a nice user-oriented way.
|
static void |
showStackTrace(java.awt.Component parent,
java.lang.Exception e)
Display a stack trace dialog.
|
static void |
showStackTrace(java.awt.Component parent,
java.lang.Exception e,
java.lang.String info)
Display a stack trace dialog.
|
public static final java.lang.String ACCELERATOR_KEY
public static final java.lang.String MNEMONIC_KEY
public static final java.lang.String LARGE_ICON
public static final java.lang.String ROLLOVER_ICON
public static final java.lang.String ROLLOVER_SELECTED_ICON
public static final java.lang.String SELECTED_ICON
public static void addHotKey(javax.swing.JComponent pane, javax.swing.Action action)
public static void addHotKey(javax.swing.JComponent pane, javax.swing.Action action, javax.swing.KeyStroke key)
public static void addIcons(javax.swing.Action action, java.lang.String[][] iconRoles)
action
- The action to which the icons are added.iconRoles
- A matrix of Strings, where each element
consists of two Strings, the absolute URL of the icon
and the key that represents the role of the icon. The keys
are usually static fields from this class, such as
LARGE_ICON
, ROLLOVER_ICON
,
ROLLOVER_SELECTED_ICON
or SELECTED_ICON
.public static javax.swing.JMenuItem addMenuItem(javax.swing.JMenu menu, javax.swing.Action action)
public static javax.swing.JMenuItem addMenuItem(javax.swing.JMenu menu, javax.swing.Action action, int mnemonic, java.lang.String tooltip)
public static javax.swing.JMenuItem addMenuItem(javax.swing.JMenu menu, java.lang.String label, javax.swing.Action action, int mnemonic, java.lang.String tooltip, boolean isEnabled)
public static javax.swing.JButton addToolBarButton(javax.swing.JToolBar toolbar, javax.swing.Action action)
public static javax.swing.JButton addToolBarButton(javax.swing.JToolBar toolbar, javax.swing.Action action, java.lang.String tooltip, javax.swing.Icon icon)
public static javax.swing.JButton addToolBarButton(javax.swing.JToolBar toolbar, javax.swing.Action action, java.lang.String tooltip, javax.swing.Icon icon, boolean isEnabled)
public static javax.swing.JButton addToolBarButton(javax.swing.JToolBar toolbar, javax.swing.Action action, java.lang.String tooltip, java.lang.String lbl)
public static javax.swing.JButton addToolBarButton(javax.swing.JToolBar toolbar, javax.swing.Action action, java.lang.String tooltip, javax.swing.Icon icon, java.lang.String lbl)
public static javax.swing.JButton addToolBarButton(javax.swing.JToolBar toolbar, javax.swing.Action action, java.lang.String tooltip, javax.swing.Icon icon, java.lang.String lbl, boolean isEnabled)
public static java.lang.String ellipsis(java.lang.String string, int length)
public static java.lang.String getFileExtension(java.io.File file)
public static java.lang.String keyStrokeToString(javax.swing.KeyStroke key)
public static void showException(java.awt.Component parent, java.lang.Exception e, java.lang.String info)
public static void showStackTrace(java.awt.Component parent, java.lang.Exception e)
public static void showStackTrace(java.awt.Component parent, java.lang.Exception e, java.lang.String info)