|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.sciss.gui.GUIUtil
public class GUIUtil
This is a helper class containing utility static functions for common Swing / GUI operations
Method Summary | |
---|---|
static void |
constrainHeight(javax.swing.JComponent c,
int h)
Adjusts minimum, maximum and preferred size of a component so as to constrain its height to a given value. |
static void |
constrainSize(javax.swing.JComponent c,
int w,
int h)
Sets minimum, maximum and preferred size to given values. |
static void |
constrainWidth(javax.swing.JComponent c,
int w)
Adjusts minimum, maximum and preferred size of a component so as to constrain its width to a given value. |
static java.awt.Point |
convertPoint(java.awt.Component source,
java.awt.Point aPoint,
java.awt.Component destination)
Same as SwingUtilities.convertPoint, but handles JViewports properly |
static void |
convertPointFromScreen(java.awt.Point p,
java.awt.Component c)
Same as SwingUtilities.convertPointFromScreen, but handles JViewports properly |
static void |
convertPointToScreen(java.awt.Point p,
java.awt.Component c)
Same as SwingUtilities.convertPointToScreen, but handles JViewports properly |
static java.awt.Rectangle |
convertRectangle(java.awt.Component source,
java.awt.Rectangle r,
java.awt.Component destination)
|
static GradientPanel |
createGradientPanel()
|
static void |
createKeyAction(javax.swing.AbstractButton comp,
javax.swing.KeyStroke stroke)
Convenience method that will add new corresponding entries in a button's input and action map, such that a given KeyStroke |
static void |
displayError(java.awt.Component component,
java.lang.Exception exception,
java.lang.String title)
Displays an error message dialog by examining a given Exception . |
static javax.swing.Icon |
getNoWriteIcon()
Returns an Icon for a no-write
or write-protection indicator. |
static java.lang.String |
getResourceString(java.lang.String key)
|
static java.util.prefs.Preferences |
getUserPrefs()
|
static double |
getVersion()
|
static boolean |
isAlwaysOnTop(java.awt.Component c)
|
static void |
makeCompactSpringGrid(java.awt.Container parent,
int rows,
int cols,
int initialX,
int initialY,
int xPad,
int yPad)
Aligns the first rows * cols
components of parent in
a grid. |
static void |
makeSpringGrid(java.awt.Container parent,
int rows,
int cols,
int initialX,
int initialY,
int xPad,
int yPad)
Aligns the first rows * cols
components of parent in
a grid. |
static void |
printSizes(java.awt.Component c)
A debugging utility that prints to stdout the component's minimum, preferred, and maximum sizes. |
static boolean |
setAlwaysOnTop(java.awt.Component c,
boolean b)
|
static void |
setDeepFont(java.awt.Container c,
java.awt.Font fnt)
Set a font for a container and all children we can find in this container (calling this method recursively). |
static void |
setInitialDialogFocus(javax.swing.JComponent c)
Passes keyboard focus to a given component when that component is to be presented in a dialog. |
static void |
setPreferences(java.awt.Container c,
java.util.prefs.Preferences prefs)
|
static void |
wrapWindowBounds(java.awt.Rectangle wr,
java.awt.Rectangle sr)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static final java.util.prefs.Preferences getUserPrefs()
public static final double getVersion()
public static final java.lang.String getResourceString(java.lang.String key)
public static void displayError(java.awt.Component component, java.lang.Exception exception, java.lang.String title)
Exception
. Returns
after the dialog was closed by the user.
component
- the component in which to open the dialog.
null
is allowed in which case
the dialog will appear centered on the screen.exception
- the exception that was thrown. the message's
text is displayed using the getLocalizedMessage
method.title
- name of the action in which the error occurredJOptionPane.showOptionDialog( Component, Object, String, int, int, Icon, Object[], Object )
,
Throwable.getLocalizedMessage()
public static void createKeyAction(javax.swing.AbstractButton comp, javax.swing.KeyStroke stroke)
KeyStroke will cause a
DoClickAction
to be performed on that button.
The key stroke is performed whenever the button is in
the current focussed window.
- Parameters:
comp
- an AbstractButton
to which a
a new keyboard action is attached.stroke
- the KeyStroke
which causes a
click on the button.- See Also:
DoClickAction
,
JComponent.getInputMap( int )
,
JComponent.getActionMap()
,
JComponent.WHEN_IN_FOCUSED_WINDOW
public static void setDeepFont(java.awt.Container c, java.awt.Font fnt)
setFont
on a JPanel
does not
cause the Font
of the
gadgets contained in the panel to
change their fonts.
c
- the container to traverse
for children whose font is to be changedfnt
- the new font to apply; if null
the current application's window handler's
default font is usedComponent.setFont( Font )
public static void setPreferences(java.awt.Container c, java.util.prefs.Preferences prefs)
public static void printSizes(java.awt.Component c)
public static void makeSpringGrid(java.awt.Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad)
rows
* cols
components of parent
in
a grid. Each component is as big as the maximum
preferred width and height of the components.
The parent is made just big enough to fit them all.
The code is taken from the Sun Swing Tutorial Site.
rows
- number of rowscols
- number of columnsinitialX
- x location to start the grid atinitialY
- y location to start the grid atxPad
- x padding between cellsyPad
- y padding between cellspublic static void makeCompactSpringGrid(java.awt.Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad)
rows
* cols
components of parent
in
a grid. Each component in a column is as wide as the maximum
preferred width of the components in that column;
height is similarly determined for each row.
The parent is made just big enough to fit them all.
The code is based on one from the Sun Swing Tutorial Site. It was optimized and includes support for hidden components.
rows
- number of rowscols
- number of columnsinitialX
- x location to start the grid atinitialY
- y location to start the grid atxPad
- x padding between cellsyPad
- y padding between cellspublic static javax.swing.Icon getNoWriteIcon()
Icon
for a no-write
or write-protection indicator. The icon has
a dimension of 16x16 pixels with transparent background.
public static GradientPanel createGradientPanel()
public static void constrainWidth(javax.swing.JComponent c, int w)
c
- the component to constrainw
- the width in pixelspublic static void constrainHeight(javax.swing.JComponent c, int h)
c
- the component to constrainh
- the height in pixelspublic static void constrainSize(javax.swing.JComponent c, int w, int h)
c
- the component to constrainw
- the width in pixelsh
- the height in pixelspublic static void wrapWindowBounds(java.awt.Rectangle wr, java.awt.Rectangle sr)
public static void setInitialDialogFocus(javax.swing.JComponent c)
AncestorListener
to the component, detecting when its parent container
is made visible. This is usefull for defining an
initial focus owner in JOptionPane
calls for example.
c
- the component to make focussed once its parent container is shownpublic static boolean setAlwaysOnTop(java.awt.Component c, boolean b)
public static boolean isAlwaysOnTop(java.awt.Component c)
public static java.awt.Point convertPoint(java.awt.Component source, java.awt.Point aPoint, java.awt.Component destination)
public static void convertPointToScreen(java.awt.Point p, java.awt.Component c)
public static void convertPointFromScreen(java.awt.Point p, java.awt.Component c)
public static java.awt.Rectangle convertRectangle(java.awt.Component source, java.awt.Rectangle r, java.awt.Component destination)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |