|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ehsbe.commons.gui.Util
public class Util
Some GUI utils
Field Summary | |
---|---|
static String |
HELP_ID_KEY
the property name for help key IDs used in JComponent Classes |
static KeyStroke |
KEY_F1
common key to use for displaying help |
static KeyStroke |
KEY_HELP
common key to use for displaying help |
Constructor Summary | |
---|---|
Util()
|
Method Summary | |
---|---|
static void |
center(Component c)
Set the location of the given component so, that it is centered on the screen. |
static Component |
findFocusOwner(Component comp)
Get the child component which has focus with respects of specified component. |
static String |
getHelpID(Object comp)
Convinience method find the help ID for the given component. |
static Window |
getWindowForComponent(Component parentComponent)
Returns the specified component's toplevel Frame or
Dialog . |
static void |
makeTreeCheckable(JTree tree)
Convinience method, which makes a tree checkable by adding an appropriate mouse listener as well as a default tree cell renderer and key listener. |
static void |
registerKbdAction(KeyStroke ks,
Action action,
JComponent comp,
int condition)
Register an action to be invoked, if the given component receives an event for the given keystroke and condition. |
static void |
registerTooltipComponent(JComponent comp)
Workaround for static tooltips - the JComponents original setTooltip does not register a component, if its getTooltip() return a none- null value. |
static void |
restoreLocationAndSize(Component comp,
String prefix,
Class<?> pkgClass,
int width,
int height,
int x,
int y)
Restore the size and location of the given component from stored user preferences. |
static void |
saveLocationAndSize(Component comp,
String prefix,
Class<?> pkgClass,
Point location)
Save the location and size of the given component to the user preference node, described by the given class with the given key prefix. |
static void |
setHelpID(Object comp,
String id)
Convinience method to assign a help ID to the specified component. |
static void |
showGeneralError(String msg,
Component comp)
Convinience method to show an general error dialog. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String HELP_ID_KEY
public static final KeyStroke KEY_F1
public static final KeyStroke KEY_HELP
Constructor Detail |
---|
public Util()
Method Detail |
---|
public static final Window getWindowForComponent(Component parentComponent) throws HeadlessException
Frame
or
Dialog
.
parentComponent
- the Component
to check for a Frame
or Dialog
Frame
or Dialog
that contains
the component, or the default frame if the component is
null
, or does not have a valid Frame
or Dialog
parent
HeadlessException
- if GraphicsEnvironment.isHeadless
returns
true
GraphicsEnvironment.isHeadless()
public static final void saveLocationAndSize(Component comp, String prefix, Class<?> pkgClass, Point location)
comp
- information source. Ignored if null
.prefix
- preference key prefix to use.pkgClass
- class to use for obtaining user preferences.location
- use this location, if the component is not visible anymore (in
which case one can not determine the location on the screen
anymore). Ignored if null
.public static final void restoreLocationAndSize(Component comp, String prefix, Class<?> pkgClass, int width, int height, int x, int y)
comp
- component to size and position on the screenprefix
- preference key prefix to use.pkgClass
- class to use for obtaining user preferences.width
- default width to use, if there is no appropriate key or the
stored value is < 10height
- default height to use, if there is no appropriate key or the
stored value is < 10x
- default x position on the screen to set, if there is no
appropriate keyy
- default y position on the screen to set, if there is no
appropriate keypublic static void center(Component c)
c
- component to center. Ignored if null
.public static void registerKbdAction(KeyStroke ks, Action action, JComponent comp, int condition)
Does nothing, if the given keystroke or component is null
.
The keystroke and action are registered with the action's command key value.
ks
- keystroke to registeraction
- action to associate with the given keystroke. If
null
the action for the given keystroke is
removed from the components action map and the keystroke is
removed from the components input map.comp
- where to bind the keystrokecondition
- on which condition the action should be fired. Values are the
same as for JComponent.getInputMap(int)
IllegalArgumentException
- if condition has an invalid valuepublic static void setHelpID(Object comp, String id)
Does nothing, if the specified component is null
. If the given
component is a JComponent
, the help ID gets put into the client
property map with the key HELP_ID_KEY
. Otherwise it gets put
into a static local map of this class.
comp
- component to which assign the given idid
- ID to assign. If null
, the currently assigned
ID (if any) is unassigned wrt. the given component.public static String getHelpID(Object comp)
One needs to register, i.e. associate the help ID with the component
before this works (see setHelpID(Object, String)
).
comp
- component to use for help ID lookup. Ignored if null
.
null
if no help ID has been found, the help ID otherwise.public static Component findFocusOwner(Component comp)
comp
- the component to use as root for the focus lookup
null
if no focus owning child has been found and
the given component has itself not the focus, the focus owning
component otherwise.public static void showGeneralError(String msg, Component comp)
msg
- message to displaycomp
- where to anchor the dialog.public static void makeTreeCheckable(JTree tree)
tree
- tree to make checkableCheckTreeCellRenderer
,
CheckableTreeMouseAdapter
public static final void registerTooltipComponent(JComponent comp)
null
value. So one has the choice to check, whether the
shared TooltipManager instance is already listening on the component
and if so simply do nothing (this is what this method does) or always
register the component on the tooltip manager for each set, which would
be a little bit more resource intensive.
comp
- component to register with the tooltipmanager, if not
already done.
|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |