com.tensegrity.gui.swing
Class SwingUtil

java.lang.Object
  extended bycom.tensegrity.gui.swing.SwingUtil

public class SwingUtil
extends java.lang.Object

This class consists of common swing utility methods. This is the place for small convenience methods which should not be duplicated in every place they are needed. This class provides all sorts of methods involving Control creation, Layout helpers and message boxes.

Version:
$Id: SwingUtil.java,v 1.197 2006/03/02 11:41:40 BurkhardWick Exp $
Author:
StepanRutz, GillesIachelini, AndreasEbbert, S�bastien Guyon, MartinGerlach

Nested Class Summary
static class SwingUtil.ActionCommand
          An Action-delegate class.
static class SwingUtil.ChoiceCommandMenuItem
          Subclass of JMenuItem to delegate the isEnabled call to the command and the isSelected() to the ToggleCommand.
static interface SwingUtil.CommandItem
          The CommandItem encapsulates the basic behavior for an item which is associated to a Command.
static class SwingUtil.CommandMenuItem
          Subclass of JMenuItem to delegate the isEnabled call to the command.
static class SwingUtil.CommandToggleButton
          Subclass of JToggleButton to delegate the isSelected call to the command and the isSelected() to the ToggleCommand.
static class SwingUtil.ToggleCommandMenuItem
          Subclass of JMenuItem to delegate the isEnabled call to the command and the isSelected() to the ToggleCommand.
 
Field Summary
static int CANCEL
          Global flags that identify options for buttons in dialogs.
static int CLOSED
          Global flags that identify options for buttons in dialogs.
static java.lang.String DEFAULT_ICON
          This is a custom property for swing actions which defines a default icon, which should be used for LnF's different from the Tensegrity LnF.
static int HORIZONTAL_POSITIONHINT_CENTER
          Horizontal positionhints for dialog showing.
static int HORIZONTAL_POSITIONHINT_LEFT
          Horizontal positionhints for dialog showing.
static int HORIZONTAL_POSITIONHINT_RIGHT
          Horizontal positionhints for dialog showing.
static java.awt.Insets insDefault
          The default insets used in dialog layouts
static char MNEMONIC_INDICATOR
          Character representing the mnemonic indicator to be used when adding mnemonics to Menus and Menu Items.
static int NO
          Global flags that identify options for buttons in dialogs.
static java.lang.String TENSEGRITY_ICON
          The name of the property which holds the icon for the Tensegrity LookAndFeel.
static int VERTICAL_POSITIONHINT_BOTTOM
          Vertical positionhints for dialog showing.
static int VERTICAL_POSITIONHINT_CENTER
          Vertical positionhints for dialog showing.
static int VERTICAL_POSITIONHINT_TOP
          Vertical positionhints for dialog showing.
static int YES
          Global flags that identify options for buttons in dialogs.
 
Method Summary
static void addComponent(java.awt.Container container, java.awt.Component component, int fill, int gX, int gY, int gW, int gH, double wX, double wY)
          Adds a component to the container which must have gridbag layout.
static void addComponent(java.awt.Container container, java.awt.Component component, int fill, int gX, int gY, int gW, int gH, double wX, double wY, java.awt.Insets insets)
          Adds a component to the container which must have gridbag layout.
static void addToGridBagLayout(java.awt.Container container, java.awt.Component component, int fill, int gX, int gY, int gW, int gH, double wX, double wY)
          add the given Component to the GridBagLayout of the given Container.
static void addToGridBagLayout(java.awt.Container container, java.awt.Component component, int fill, int gX, int gY, int gW, int gH, double wX, double wY, java.awt.Insets insets)
          add the given Component to the GridBagLayout of the given Container.
static void addToGridBagLayout(java.awt.Container container, java.awt.Component component, int fill, int gX, int gY, int gW, int gH, double wX, double wY, int anchor)
          add the given Component to the GridBagLayout of the given Container.
static javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu, java.util.HashMap uiMap, java.lang.String id, Command command, javax.swing.KeyStroke ks, java.lang.String iconurl, java.lang.Class resourceClass, UIManager uiManager)
          Creates a menu item and adds it to the specified menu.
static javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu, java.util.HashMap uiMap, java.lang.String id, Command command, javax.swing.KeyStroke ks, UIManager uiManager)
          Creates a menu item and adds it to the specified menu.
static javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu, java.util.HashMap uiMap, java.lang.String id, Command command, java.lang.String iconurl, java.lang.Class resourceClass, UIManager uiManager)
          Creates a menu item and adds it to the specified menu.
static javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu, java.util.HashMap uiMap, java.lang.String id, Command command, UIManager uiManager)
          Creates a menu item and adds it to the specified menu.
static javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu, java.util.HashMap uiMap, java.lang.String id, Command command, UIManager uiManager, javax.swing.Icon icon)
          Creates a menu item and adds it to the specified menu.
static javax.swing.JMenuItem addToMenu(javax.swing.JPopupMenu menu, java.util.HashMap uiMap, java.lang.String id, Command command, javax.swing.KeyStroke ks, java.lang.String iconurl, java.lang.Class resourceClass, UIManager uiManager)
          Creates a menu item and adds it to the specified menu.
static javax.swing.JMenuItem addToMenu(javax.swing.JPopupMenu menu, java.util.HashMap uiMap, java.lang.String id, Command command, javax.swing.KeyStroke ks, java.lang.String iconurl, java.lang.String rollovericonurl, java.lang.Class resourceClass, UIManager uiManager)
          Creates a menu item and adds it to the specified menu.
static javax.swing.JMenuItem addToMenu(javax.swing.JPopupMenu menu, java.util.HashMap uiMap, java.lang.String id, Command command, javax.swing.KeyStroke ks, UIManager uiManager)
          Creates a menu item and adds it to the specified menu.
static javax.swing.JMenuItem addToMenu(javax.swing.JPopupMenu menu, java.util.HashMap uiMap, java.lang.String id, Command command, java.lang.String iconurl, java.lang.Class resourceClass, UIManager uiManager)
          Creates a menu item and adds it to the specified menu.
static javax.swing.JMenuItem addToMenu(javax.swing.JPopupMenu menu, java.util.HashMap uiMap, java.lang.String id, Command command, UIManager uiManager)
          Creates a menu item and adds it to the specified menu.
static javax.swing.AbstractButton addToToolBar(UIManager uiManager, javax.swing.JToolBar toolbar, Command command, Icon icon)
          Method addToToolbar adds a given command as item to the given toolbar.
static javax.swing.AbstractButton addToToolBar(UIManager uiManager, javax.swing.JToolBar toolbar, Command command, java.lang.String iconurl, java.lang.Class resourceClass)
          Method addToToolbar adds a given command as item to the given ToolBar.
static javax.swing.AbstractButton addToToolBar(UIManager uiManager, javax.swing.JToolBar toolbar, Command command, java.lang.String iconurl, java.lang.String deficonurl, java.lang.Class resourceClass)
          Method addToToolbar adds a given command as item to the given toolbar.
static javax.swing.JToggleButton addToToolBarToggleButton(UIManager uiManager, javax.swing.JToolBar toolbar, Command command, Icon icon, Icon iconToggled, int index)
          Method addToToolbar inserts a given command as item at a specific index of the toolbar.
static javax.swing.JToggleButton addToToolBarToggleButton(UIManager uiManager, javax.swing.JToolBar toolbar, Command command, java.lang.String iconurl, java.lang.Class resourceClass)
          Adds a new togglebutton to the given toolbar.
static javax.swing.JToggleButton addToToolBarToggleButton(UIManager uiManager, javax.swing.JToolBar toolbar, Command command, java.lang.String iconurl, java.lang.String iconurlToggled, java.lang.Class resourceClass)
          Adds a new togglebutton to the given toolbar.
static javax.swing.JToggleButton addToToolBarToggleButton(UIManager uiManager, javax.swing.JToolBar toolbar, Command command, java.lang.String iconurl, java.lang.String iconurlToggled, java.lang.Class resourceClass, int index)
          Method addToToolbar inserts a given command as item at a specific index of the toolbar.
static void alignMenuItems(javax.swing.JComponent menu)
          This method aligns all MenuElements of the given Menu Component evenly according to a "normal" MenuItem with an Icon.
static void busyEnd(java.awt.Component busyComponent)
          Decreases the busy counter of the given component and sets the default cursor, if the counter reaches 0.
static void busyStart(java.awt.Component busyComponent)
          Sets the busy cursor on the given component.
static boolean canWriteFormat(java.lang.String formatName)
          Returns true if the specified format name can be written
static javax.swing.Action commandToAction(Command command)
          The method commandToAction returns a swing action instance for a given generic command.
static javax.swing.Action commandToAction(Command command, UIManager uiManager)
          Wraps a command into an action, so that it can be used in the world of swing.
static javax.swing.JPanel createList(java.awt.Component[] comps)
          Creates a List of components along the Y-Axis.
static javax.swing.JPanel createTable(java.awt.Component[] left, java.awt.Component[] right)
          Creates a panel with GridBagLayout which layouts the given JComponent arrays like a table, where the left[] is the column 0 and the right the column 1.
static javax.swing.border.Border createTitleFrameBorder(java.lang.String title, int top, int left, int bottom, int right)
          Method createTitleFrameBorder creates a compound border consisting of 3 Borders: A titled border with default text alignment and font, an etched border for grouping effect and an emptyborder to have some insets.
static javax.swing.JToggleButton createToggleButton(javax.swing.AbstractAction action, ToggleCommand command)
          Creates a toggle button, that changes its state according to the state of the togglecommand.
static void doWhenVisible(java.awt.Component component, java.lang.Runnable runnable)
          Runs the Runnable when the given component got a valid size.
static void drawString(javax.swing.JComponent comp, java.awt.Graphics2D g2d, java.lang.String str)
          Draws the given string antialiased and centered into the graphics.
static void drawString(javax.swing.JComponent comp, java.awt.Graphics2D g2d, java.lang.String str, java.awt.Insets additionalInsets)
          Draws the given string antialiased and centered into the graphics.
static void dumpComponentTree(java.awt.Component component)
          Dumps the swing component tree starting at the given root component.
static java.awt.Rectangle findBounds(java.awt.Component component)
          Finds the coordinates of the component in the given container.
static java.awt.Point findCenterPointOnScreen(java.awt.Component component)
          Finds the coordinates of the component in the given container.
static java.awt.Component findChild(java.awt.Container cont, java.lang.Class type)
          Returns the first child matching the given class type
static java.awt.Component findRoot(java.awt.Component component)
          Finds the most top-level parent of a given component.
static java.awt.Component findRoot(java.awt.Component component, java.lang.Class constraint)
          Finds the most top-level parent of a given component.
static int getIndexOfMnemonic(java.lang.String text)
          Returns the first index of an unquoted mnemonic indiacator.
static javax.swing.JPanel getLabelPanel(int align)
          Creates Panel with FlowLayout, for good looking value-labels
static javax.swing.JPanel getLabelPanel(int align, int hgap, int vgap)
          Creates Panel with FlowLayout.RIGHT, for good looking value-labels
static java.awt.Rectangle getMaximumWindowBounds()
          Returns the maximum rectangle that can be used for windows
static int getMouseButton(java.awt.event.MouseEvent event)
          Returns the mouse button from the given MouseEvent
static javax.swing.MenuElement getPopupMenu()
           
static Icon getResourceIcon(java.lang.String iconurl, java.lang.Class resourceclass, java.awt.Component component, boolean trackResource)
          Loads an icon.
static java.awt.Image getResourceImage(java.lang.String iconpath, java.lang.Class resourceclass)
          Loads an icon manually, without URL resolving.
static java.awt.Image getResourceImage(java.lang.String iconpath, java.lang.Class resourceclass, java.awt.Component component, boolean trackResource)
          Loads an icon manually, without URL resolving.
static java.awt.Color getUIColor(java.lang.Object key)
          Returns the color with the given key from the current look and feel or a defaultColor if the entry does not exist.
static java.awt.Color getUIColor(java.lang.Object key, java.awt.Color defaultColor)
          Returns the color with the given key from the current look and feel or the defaultColor if the entry does not exist.
static boolean isTensegrityLookAndFeel()
          Checks whether the current look and feel is the tensegrity look and feel or not
static javax.swing.JCheckBoxMenuItem makeCheckBoxMenuItem(java.lang.String title, java.awt.event.ItemListener listener)
          This methods makes a new checkbox menuitem and assigns an action to it in one go.
static javax.swing.JCheckBoxMenuItem makeCheckBoxMenuItem(java.lang.String title, java.lang.String actionCommand, javax.swing.Action action)
          Makes a checkbox menu item.
static javax.swing.JCheckBoxMenuItem makeCheckBoxMenuItemSelected(java.lang.String title, java.awt.event.ItemListener listener)
          This methods makes a new checkbox menuitem and assigns an action to it in one go.
static javax.swing.JPanel makeCloseApplyButtonPanel(java.awt.event.ActionListener applyaction, java.awt.event.ActionListener closeaction, UIManager uiManager)
          Creates a panel with an apply and a close button.
static javax.swing.JPanel makeCloseButtonPanel(java.awt.event.ActionListener closeaction, UIManager uiManager)
          Creates a panel with a close button.
static javax.swing.JPanel makeEmbeddedComponent(java.awt.Component component)
          Creates a panel with a component that is to be left aligned under all size situations.
static javax.swing.JPanel makeImportExportButtonPanel(java.awt.event.ActionListener importaction, java.awt.event.ActionListener Exportaction, UIManager uiManager)
          Creates a panel with an import and an exportbutton.
static javax.swing.JMenuItem makeMenuItem(java.lang.String id, Command command, javax.swing.KeyStroke ks, UIManager uiManager)
          Simple helper to create menuitems based on GUI ID's.
static javax.swing.JMenuItem makeMenuItem(java.lang.String id, Command command, UIManager uiManager)
          Simple helper to create menuitems based on GUI ID's without a key accelerator.
static javax.swing.JMenuItem makeMenuItem(UIManager uiManager, java.lang.String title, java.lang.String actionCommand, Command command)
          This methods makes a new menu item and assigns an action to it in one go.
static javax.swing.JMenuItem makeMenuItem(UIManager uiManager, java.lang.String title, java.lang.String actionCommand, Command command, javax.swing.KeyStroke accelerator)
          This methods makes a new menu item and assigns an action to it in one go.
static javax.swing.JPanel makeOkCancelApplyButtonPanel(java.awt.event.ActionListener okaction, java.awt.event.ActionListener cancelaction, java.awt.event.ActionListener applyaction, UIManager uiManager)
          Creates a panel with a cancel and an ok button.
static javax.swing.JPanel makeOkCancelButtonPanel(java.awt.event.ActionListener okaction, java.awt.event.ActionListener cancelaction, UIManager uiManager)
          Creates a panel with a cancel and an ok button.
static javax.swing.JRadioButtonMenuItem makeRadioButtonMenuItem(javax.swing.ButtonGroup buttongroup, java.lang.String title, javax.swing.Action action)
          This methods makes a new radiobutton menuitem and assigns an action to it in one go.
static javax.swing.JPanel makeTitlePanel(java.lang.String text)
          Creates a panel with a jlabel that is typically used as a title for a dialog or other container.
static void paintClosingLine(java.awt.Graphics g, java.awt.Dimension d)
          Paints a closing line at the bottom of the specified Dimension.
static void paintClosingLines(java.awt.Graphics g, java.awt.Dimension d)
          Paints two closing lines at the bottom of the specified Dimension.
static java.lang.String removeMnemonicIndicator(java.lang.String text)
          Removes the '&' (The mnemonic indicator) from texts that are used for menu entries.
static void requestFocus(java.awt.Component comp)
          Requests the focus for the given component.
static boolean runningJDK1_4()
           
static boolean saveImageAsBMP(java.awt.image.BufferedImage image, java.io.File file)
          This method will save the given BufferedImageinstance and will save it to the specified file in 24bitplane uncompressed mode.
static boolean saveImageAsBMP(java.awt.image.BufferedImage image, java.io.OutputStream os)
          This method will save the given BufferedImageinstance and will save it to the specified output stream in 24bitplane uncompressed mode.
static boolean saveImageAsGIF(java.awt.image.BufferedImage image, java.io.File file)
          Saves the given image in File file using GIF -encoding.
static boolean saveImageAsJPEG(java.awt.image.BufferedImage image, java.io.File file, float quality, boolean forceBaseline)
          Saves the given image in File file using JPEG -encoding.
static boolean saveImageAsJPEG(java.awt.image.BufferedImage image, java.io.OutputStream stream, float quality, boolean forceBaseline)
          Saves the given image in File file using JPEG -encoding.
static boolean saveImageAsPNG(java.awt.image.RenderedImage image, java.io.File file)
          Saves the given image in File file using GIF -encoding.
static boolean saveImageAsPNG(java.awt.image.RenderedImage image, java.io.OutputStream os)
          This method basically uses the #saveImagesAs(String, RenderedImage, OutputStream)to save the given RenderedImage as PNG.
static void setDialogPosition(java.awt.Window dialog, int horizontalPositionHint, int verticalPositionHint)
          Sets the position of the window according to the position hints
static void setDialogPosition(java.awt.Window dialog, int horizontalPositionHint, int verticalPositionHint, boolean considerMaximumWindowSize)
          Sets the position of the window according to the position hints
static boolean setHelpId(java.awt.Component comp, java.lang.String id)
          Dynamically load class javax.help.CSH and invokes method setHelpId to set a help id to be used for context sensitive help for the given Component.
static void setPopupMenu(javax.swing.MenuElement popup)
           
static void setTopLevelFrameSize(java.awt.Frame frame)
          Sets the size of the top level frame to some reasonable portion of the screen.
static boolean showConfirmDialog(java.awt.Component parent, java.lang.String text, java.lang.String title)
          Shows a confirm dialog, return true if the user confirmed.
static boolean showConfirmDialog(java.awt.Component parent, java.lang.String text, java.lang.String title, int messageType)
          Shows a confirm dialog, return true if the user confirmed.
static boolean showConfirmDialog(java.awt.Component parent, java.lang.String text, java.lang.String title, UIManager uiManager)
          Shows a confirm dialog, return true if the user confirmed.
static int showConfirmDialogWithCancel(java.awt.Component parent, java.lang.String text, java.lang.String title)
          Shows a confirm dialog, return user decision.
static int showConfirmDialogWithCancel(java.awt.Component parent, java.lang.String text, java.lang.String title, UIManager uiManager)
          Shows a confirm dialog, return user decision.
static int showConfirmDialogWithCancel(java.awt.Component parent, java.lang.String text, java.lang.String title, UIManager uiManager, int messageType)
          Shows a confirm dialog, return user decision.
static void showDialog(java.awt.Dialog dialog)
          Shows a dialog in the center.
static void showDialog(java.awt.Window dialog)
          Shows a dialog in the center.
static void showDialog(java.awt.Window dialog, int horizontalPositionHint, int verticalPositionHint)
          Shows a dialog at the given position which is specified by the hints.
static void showDialog(java.awt.Window dialog, int horizontalPositionHint, int verticalPositionHint, boolean considerMaximumWindowSize)
          Shows a dialog at the given position which is specified by the hints.
static void showError(java.awt.Component parent, java.lang.String message)
          Deprecated. Use other method, because of the hard coded title string!
static void showError(java.awt.Component parent, java.lang.String message, java.lang.String title)
          Shows a modal error dialog.
static void showFrame(java.awt.Frame frame, int horizontalPositionHint, int verticalPositionHint)
          Shows a dialog at the given position which is specified by the hints.
static int showYesNo(java.awt.Component parent, java.lang.String message)
          Deprecated. use showConfirmDialog(Component, String, String)
static int showYesNo(java.awt.Component parent, java.lang.String message, java.lang.String title)
          Deprecated. use showConfirmDialog(Component, String, String)
static int showYesNo(java.awt.Component parent, java.lang.String message, java.lang.String title, int messageType)
          Deprecated. use showConfirmDialog(Component, String, String, int)
static int showYesNoCancel(java.awt.Component parent, java.lang.String message)
          Deprecated. use showConfirmDialogWithCancel(Component, String, String)
static void unregisterMenu(javax.swing.JMenu menu, java.util.HashMap uiMap)
          VIP method to unregister a menu from the uimap.
static void unregisterMenu(javax.swing.JPopupMenu menu, java.util.HashMap uiMap)
          VIP method to unregister a menu from the uimap.
static void updateComponentTreeUI(java.awt.Component c)
          A simple minded look and feel change: ask each node in the tree to updateUI() -- that is, to initialize its UI property with the current look and feel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

insDefault

public static final java.awt.Insets insDefault
The default insets used in dialog layouts


MNEMONIC_INDICATOR

public static final char MNEMONIC_INDICATOR
Character representing the mnemonic indicator to be used when adding mnemonics to Menus and Menu Items.

See Also:
Constant Field Values

YES

public static final int YES
Global flags that identify options for buttons in dialogs.

See Also:
Constant Field Values

NO

public static final int NO
Global flags that identify options for buttons in dialogs.

See Also:
Constant Field Values

CANCEL

public static final int CANCEL
Global flags that identify options for buttons in dialogs.

See Also:
Constant Field Values

CLOSED

public static final int CLOSED
Global flags that identify options for buttons in dialogs.

See Also:
Constant Field Values

HORIZONTAL_POSITIONHINT_LEFT

public static final int HORIZONTAL_POSITIONHINT_LEFT
Horizontal positionhints for dialog showing.

See Also:
Constant Field Values

HORIZONTAL_POSITIONHINT_CENTER

public static final int HORIZONTAL_POSITIONHINT_CENTER
Horizontal positionhints for dialog showing.

See Also:
Constant Field Values

HORIZONTAL_POSITIONHINT_RIGHT

public static final int HORIZONTAL_POSITIONHINT_RIGHT
Horizontal positionhints for dialog showing.

See Also:
Constant Field Values

VERTICAL_POSITIONHINT_TOP

public static final int VERTICAL_POSITIONHINT_TOP
Vertical positionhints for dialog showing.

See Also:
Constant Field Values

VERTICAL_POSITIONHINT_CENTER

public static final int VERTICAL_POSITIONHINT_CENTER
Vertical positionhints for dialog showing.

See Also:
Constant Field Values

VERTICAL_POSITIONHINT_BOTTOM

public static final int VERTICAL_POSITIONHINT_BOTTOM
Vertical positionhints for dialog showing.

See Also:
Constant Field Values

DEFAULT_ICON

public static final java.lang.String DEFAULT_ICON
This is a custom property for swing actions which defines a default icon, which should be used for LnF's different from the Tensegrity LnF.

See Also:
Constant Field Values

TENSEGRITY_ICON

public static final java.lang.String TENSEGRITY_ICON
The name of the property which holds the icon for the Tensegrity LookAndFeel.

See Also:
Constant Field Values
Method Detail

getMouseButton

public static final int getMouseButton(java.awt.event.MouseEvent event)
Returns the mouse button from the given MouseEvent

Parameters:
event - the given MouseEvent
Returns:
the mouse button as defined by the constants used in MouseInfo.

setTopLevelFrameSize

public static final void setTopLevelFrameSize(java.awt.Frame frame)
Sets the size of the top level frame to some reasonable portion of the screen.

Parameters:
frame - the Frame which size should be modified.

setHelpId

public static final boolean setHelpId(java.awt.Component comp,
                                      java.lang.String id)
Dynamically load class javax.help.CSH and invokes method setHelpId to set a help id to be used for context sensitive help for the given Component. If the archive javahelp.jar is not in the classpath false will be returned.

Parameters:
comp - the Component to set a context sensitive help id for.
id - the id to set.
Returns:
false if class java.help.CSH could not be loaded.

Find more information in the class documentation


showError

public static final void showError(java.awt.Component parent,
                                   java.lang.String message)
Deprecated. Use other method, because of the hard coded title string!

Shows a modal error dialog.

Parameters:
parent - the parent component.
message - the message string to display in the dialog.
See Also:
showError(Component, String, String)

showError

public static final void showError(java.awt.Component parent,
                                   java.lang.String message,
                                   java.lang.String title)
Shows a modal error dialog.

Parameters:
parent - the parent component for this message box.
message - the message string to display in the dialog.
title - The title string to display in the dialog.

showYesNoCancel

public static int showYesNoCancel(java.awt.Component parent,
                                  java.lang.String message)
Deprecated. use showConfirmDialogWithCancel(Component, String, String)

Method showYesNoCancel shows a messagebox with a Yes/No/Cancel button bar.

Parameters:
parent - the parent component for this message box.
message - the message as String
Returns:
int the return value which is YES,NO or CANCEL.

showYesNo

public static int showYesNo(java.awt.Component parent,
                            java.lang.String message)
Deprecated. use showConfirmDialog(Component, String, String)

Method showYesN shows a MessageBox with a Yes/No button bar.

Parameters:
parent - the parent component for this message box.
message - the message as String
Returns:
int the return value which is YES,NO or CANCEL.

showYesNo

public static int showYesNo(java.awt.Component parent,
                            java.lang.String message,
                            java.lang.String title)
Deprecated. use showConfirmDialog(Component, String, String)

Method showYesN shows a MessageBox with a Yes/No button bar.

Parameters:
parent - the parent component for this message box.
message - the message as String.
title - the title for the MessageBox.
Returns:
int the return value which is YES,NO or CANCEL.

showYesNo

public static int showYesNo(java.awt.Component parent,
                            java.lang.String message,
                            java.lang.String title,
                            int messageType)
Deprecated. use showConfirmDialog(Component, String, String, int)

Method showYesN shows a MessageBox with a Yes/No button bar. This method allows you to change the icon, which is displayed on the MessageBox.

Parameters:
parent - the parent component for this message box.
message - the message as String.
title - the title for the MessageBox.
messageType - one of the following constants JOptionPane.ERROR_MESSAGE, JOptionPane.QUESTION_MESSAGE, JOptionPane.INFORMATION_MESSAGE, JOptionPane.WARNING_MESSAGE.
Returns:
int the return value which is YES,NO or CANCEL.

makeMenuItem

public static final javax.swing.JMenuItem makeMenuItem(UIManager uiManager,
                                                       java.lang.String title,
                                                       java.lang.String actionCommand,
                                                       Command command)
This methods makes a new menu item and assigns an action to it in one go.

Parameters:
uiManager - the UIManager instance to obtain localized strings from.
title - the text of the MenuItem.
actionCommand - the action command string.
command - the command associated with the MenuItem.
Returns:
the created MenuItem.

makeMenuItem

public static final javax.swing.JMenuItem makeMenuItem(UIManager uiManager,
                                                       java.lang.String title,
                                                       java.lang.String actionCommand,
                                                       Command command,
                                                       javax.swing.KeyStroke accelerator)
This methods makes a new menu item and assigns an action to it in one go.

Parameters:
uiManager - the UIManager instance to obtain localized strings from.
title - the text of the MenuItem.
actionCommand - the action command string.
command - the command associated with the MenuItem.
accelerator - the accelerator keystroke description.
Returns:
the created MenuItem.

makeRadioButtonMenuItem

public static final javax.swing.JRadioButtonMenuItem makeRadioButtonMenuItem(javax.swing.ButtonGroup buttongroup,
                                                                             java.lang.String title,
                                                                             javax.swing.Action action)
This methods makes a new radiobutton menuitem and assigns an action to it in one go. Automatically sets the more recent added button in the group to be the selected button.

Parameters:
title - the radioitem text.
Returns:
the created radiobutton menuitem.

makeCheckBoxMenuItem

public static final javax.swing.JCheckBoxMenuItem makeCheckBoxMenuItem(java.lang.String title,
                                                                       java.awt.event.ItemListener listener)
This methods makes a new checkbox menuitem and assigns an action to it in one go.

Parameters:
title - the radioitem text.
listener - the item listener of the checkbox
Returns:
the created checkbox menuitem.

makeCheckBoxMenuItemSelected

public static final javax.swing.JCheckBoxMenuItem makeCheckBoxMenuItemSelected(java.lang.String title,
                                                                               java.awt.event.ItemListener listener)
This methods makes a new checkbox menuitem and assigns an action to it in one go. The initial state of the checkbox is selected.

Parameters:
title - the radioitem text.
listener - the item listener of the checkbox
Returns:
the created checkbox menuitem.

makeCheckBoxMenuItem

public static javax.swing.JCheckBoxMenuItem makeCheckBoxMenuItem(java.lang.String title,
                                                                 java.lang.String actionCommand,
                                                                 javax.swing.Action action)
Makes a checkbox menu item.

Parameters:
title - the checkbox title
actionCommand - the action command string.
action - the action to associate with the checkbox.
Returns:
the assembled checkbox.

makeTitlePanel

public static final javax.swing.JPanel makeTitlePanel(java.lang.String text)
Creates a panel with a jlabel that is typically used as a title for a dialog or other container.

Parameters:
text - the text to display as the title.
Returns:
the panel with the title label inside.

createList

public static javax.swing.JPanel createList(java.awt.Component[] comps)
Creates a List of components along the Y-Axis. This method returns a gridbaglayouted container, where all the given parameter components are layouted from top to bottom. Components are resized Horizontal, but not vertical. Note : The layout uses the available space of the target container. If there is more space then needed, the components are distributed over the available space.

Parameters:
comps - an array of components.
Returns:
a JPanel containing the given layouted components.

createTable

public static javax.swing.JPanel createTable(java.awt.Component[] left,
                                             java.awt.Component[] right)
Creates a panel with GridBagLayout which layouts the given JComponent arrays like a table, where the left[] is the column 0 and the right the column 1.

Parameters:
left - an array of components.
right - an array of components.
Returns:
JPanel the table-alike layouted panel.

makeEmbeddedComponent

public static final javax.swing.JPanel makeEmbeddedComponent(java.awt.Component component)
Creates a panel with a component that is to be left aligned under all size situations. This will internally use a gridlayout and thus the panel will be fully filled with the given component.

Parameters:
component - the component to embedd.
Returns:
the panel with the embedded component inside

makeOkCancelApplyButtonPanel

public static final javax.swing.JPanel makeOkCancelApplyButtonPanel(java.awt.event.ActionListener okaction,
                                                                    java.awt.event.ActionListener cancelaction,
                                                                    java.awt.event.ActionListener applyaction,
                                                                    UIManager uiManager)
Creates a panel with a cancel and an ok button.

Parameters:
okaction - the listener to call if ok is pressed.
cancelaction - the listener to call if ok is pressed.
applyaction - the listener to call without closing a dialog.
uiManager - the UIManager instance to obtain localized strings from.

makeCloseApplyButtonPanel

public static final javax.swing.JPanel makeCloseApplyButtonPanel(java.awt.event.ActionListener applyaction,
                                                                 java.awt.event.ActionListener closeaction,
                                                                 UIManager uiManager)
Creates a panel with an apply and a close button.

Parameters:
applyaction - the action to apply without closing a dialog.
closeaction - the action to apply if ok is pressed.
uiManager - the UIManager instance to obtain localized strings from.
Returns:
the panel with the ok, cancel and apply buttons inside.

makeImportExportButtonPanel

public static final javax.swing.JPanel makeImportExportButtonPanel(java.awt.event.ActionListener importaction,
                                                                   java.awt.event.ActionListener Exportaction,
                                                                   UIManager uiManager)
Creates a panel with an import and an exportbutton.

Parameters:
importaction - the action to apply without closing a dialog.
Exportaction - the action to apply if ok is pressed.
uiManager - the UIManager instance to obtain localized strings from.
Returns:
the panel with the ok, cancel and apply buttons inside.

makeOkCancelButtonPanel

public static final javax.swing.JPanel makeOkCancelButtonPanel(java.awt.event.ActionListener okaction,
                                                               java.awt.event.ActionListener cancelaction,
                                                               UIManager uiManager)
Creates a panel with a cancel and an ok button.

Parameters:
okaction - the listener to inform if ok is pressed.
cancelaction - the listener to inform if ok is pressed.
uiManager - the ui manager for getting the button text ( GUIItem.OK_BUT_IDS,GUIItem.CANCEL_BUT_IDS ).May be null, but than there will be no text after creation.
Returns:
the panel with the ok and cancel buttons inside.

makeCloseButtonPanel

public static final javax.swing.JPanel makeCloseButtonPanel(java.awt.event.ActionListener closeaction,
                                                            UIManager uiManager)
Creates a panel with a close button.

Parameters:
closeaction - the action to apply if close is pressed.
uiManager - the UIManager instance to obtain localized strings from.
Returns:
the panel with the close button inside.

addToGridBagLayout

public static final void addToGridBagLayout(java.awt.Container container,
                                            java.awt.Component component,
                                            int fill,
                                            int gX,
                                            int gY,
                                            int gW,
                                            int gH,
                                            double wX,
                                            double wY)
add the given Component to the GridBagLayout of the given Container.

Parameters:
container - the container with the grid bag layout
component - the component to add
fill - the fill constant for the grid bag layout
gX - the x position in the grid
gY - the y position in the grid
gW - the number of cells to be spanned in a row
gH - the number of cells to be spanned in a column
wX - the specification of how additionally space is used
wY - the specification of how additionally space is used
See Also:
GridBagLayout, GridBagConstraints

addToGridBagLayout

public static final void addToGridBagLayout(java.awt.Container container,
                                            java.awt.Component component,
                                            int fill,
                                            int gX,
                                            int gY,
                                            int gW,
                                            int gH,
                                            double wX,
                                            double wY,
                                            java.awt.Insets insets)
add the given Component to the GridBagLayout of the given Container.

Parameters:
container - the container with the grid bag layout
component - the component to add
fill - the fill constant for the grid bag layout
gX - the x position in the grid
gY - the y position in the grid
gW - the number of cells to be spanned in a row
gH - the number of cells to be spanned in a column
wX - the specification of how additionally space is used
wY - the specification of how additionally space is used
insets - The insets for the added component
See Also:
GridBagLayout, GridBagConstraints

addToGridBagLayout

public static final void addToGridBagLayout(java.awt.Container container,
                                            java.awt.Component component,
                                            int fill,
                                            int gX,
                                            int gY,
                                            int gW,
                                            int gH,
                                            double wX,
                                            double wY,
                                            int anchor)
add the given Component to the GridBagLayout of the given Container.

Parameters:
container - the container with the grid bag layout
component - the component to add
fill - the fill constant for the grid bag layout
gX - the x position in the grid
gY - the y position in the grid
gW - the number of cells to be spanned in a row
gH - the number of cells to be spanned in a column
wX - the specification of how additionally space is used
wY - the specification of how additionally space is used
anchor - the anchor for the component to add
See Also:
GridBagLayout, GridBagConstraints

getLabelPanel

public static final javax.swing.JPanel getLabelPanel(int align)
Creates Panel with FlowLayout, for good looking value-labels

Parameters:
align - the flowlayout alighment.
Returns:
the jpanel with the right aligned flowlayout

getLabelPanel

public static final javax.swing.JPanel getLabelPanel(int align,
                                                     int hgap,
                                                     int vgap)
Creates Panel with FlowLayout.RIGHT, for good looking value-labels

Parameters:
align - the flowlayout alighment.
Returns:
the jpanel with the right aligned flowlayout

findRoot

public static final java.awt.Component findRoot(java.awt.Component component)
Finds the most top-level parent of a given component. Returns the component itself if no parents exists.

Parameters:
component - the component to search from.
Returns:
the most top-level parent.

findRoot

public static final java.awt.Component findRoot(java.awt.Component component,
                                                java.lang.Class constraint)
Finds the most top-level parent of a given component. Returns the component itself if no parents exists. The search is limited to the given class, if no parent with the given class is found and if the component itself is not of the given class, then null is returned

Parameters:
component - the component to search from.
constraint - a class constraint that must be met for any non-null result.
Returns:
the most top-level parent.

findChild

public static java.awt.Component findChild(java.awt.Container cont,
                                           java.lang.Class type)
Returns the first child matching the given class type

Parameters:
cont - The container to examine
type - The type of class to look for
Returns:
The first occurrance of a fitting component or null

findBounds

public static final java.awt.Rectangle findBounds(java.awt.Component component)
Finds the coordinates of the component in the given container.

Parameters:
component - the component of which you want to find the coordinates.
Returns:
Rectangle the rectangle containing the position and size of the component.

findCenterPointOnScreen

public static final java.awt.Point findCenterPointOnScreen(java.awt.Component component)
Finds the coordinates of the component in the given container.

Parameters:
component - the component of which you want to find the coordinates.
Returns:
Point the position of the component as an instance of class java.awt.Point.

commandToAction

public static javax.swing.Action commandToAction(Command command)
The method commandToAction returns a swing action instance for a given generic command. This method should not longer be used.

Parameters:
command - the Command you want be converted to a swing action
Returns:
Action the Action.
See Also:
commandToAction(Command, UIManager)

commandToAction

public static javax.swing.Action commandToAction(Command command,
                                                 UIManager uiManager)
Wraps a command into an action, so that it can be used in the world of swing.

Parameters:
command - the command to wrap.
uiManager - the UIManager to get the localized string from.
Returns:
an action that wraps the command.

makeMenuItem

public static javax.swing.JMenuItem makeMenuItem(java.lang.String id,
                                                 Command command,
                                                 javax.swing.KeyStroke ks,
                                                 UIManager uiManager)
Simple helper to create menuitems based on GUI ID's.

Parameters:
id - the id of the text
command - the command associated with the menuitem.
ks - the keystroke to assign to the menuitem.
uiManager - the UIManager instance to obtain localized strings from.
Returns:
the created JMenuItem.

makeMenuItem

public static javax.swing.JMenuItem makeMenuItem(java.lang.String id,
                                                 Command command,
                                                 UIManager uiManager)
Simple helper to create menuitems based on GUI ID's without a key accelerator.

Parameters:
id - the id of the text
command - the command associated with the menuitem.
uiManager - the UIManager instance to obtain localized strings from.
Returns:
the created JMenuItem.

addToMenu

public static javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu,
                                              java.util.HashMap uiMap,
                                              java.lang.String id,
                                              Command command,
                                              javax.swing.KeyStroke ks,
                                              UIManager uiManager)
Creates a menu item and adds it to the specified menu. The given action is assinged to the item. The id and the uimap reference are used to determine the text string for the menu item.

Parameters:
menu - the menu to add the new menuitem to.
uiMap - the uimap for text lookup.
id - the id of the text
command - the command associated with the menuitem.
ks - the keystroke to assign to the menuitem.
uiManager - the UIManager to get the localized string from.
Returns:
the created JMenuItem.

removeMnemonicIndicator

public static java.lang.String removeMnemonicIndicator(java.lang.String text)
Removes the '&' (The mnemonic indicator) from texts that are used for menu entries. The character can be quoted by doubling it '&&', if it's used as normal ampersand. e.g. "Copy && Paste"

Parameters:
text - The text to change
Returns:
The text without single '&'

getIndexOfMnemonic

public static int getIndexOfMnemonic(java.lang.String text)
Returns the first index of an unquoted mnemonic indiacator.

Parameters:
text - The text to look through
Returns:
the first index of an unquoted mnemonic indiacator.

addToMenu

public static javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu,
                                              java.util.HashMap uiMap,
                                              java.lang.String id,
                                              Command command,
                                              javax.swing.KeyStroke ks,
                                              java.lang.String iconurl,
                                              java.lang.Class resourceClass,
                                              UIManager uiManager)
Creates a menu item and adds it to the specified menu. The given action is assinged to the item. The id and the uimap reference are used to determine the text string for the menu item.

Parameters:
menu - the menu to add the new menuitem to.
uiMap - the uimap for text lookup.
id - the id of the text
command - the command associated with the menuitem.
ks - the keystroke to assign to the menuitem.
iconurl - the url for an icon to assign to the menuitem.
resourceClass - the class to load the resources from.
uiManager - the UIManager to get the localized string from.
Returns:
JMenuItem the new MenuItem.

addToMenu

public static javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu,
                                              java.util.HashMap uiMap,
                                              java.lang.String id,
                                              Command command,
                                              UIManager uiManager)
Creates a menu item and adds it to the specified menu. The given action is assinged to the item. The id and the uimap reference are used to determine the text string for the menu item.

Parameters:
menu - the menu to add the new menuitem to.
uiMap - the uimap for text lookup.
id - the id of the text
command - the command associated with the menuitem.
uiManager - the UIManager to get the localized string from.
Returns:
the created JMenuItem.

addToMenu

public static javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu,
                                              java.util.HashMap uiMap,
                                              java.lang.String id,
                                              Command command,
                                              UIManager uiManager,
                                              javax.swing.Icon icon)
Creates a menu item and adds it to the specified menu. The given action is assinged to the item. The id and the uimap reference are used to determine the text string for the menu item. An icon is also specified.

Parameters:
menu - the menu to add the new menuitem to.
uiMap - the uimap for text lookup.
id - the id of the text
command - the command associated with the menuitem.
uiManager - the UIManager to get the localized string from.
icon - the icon to show for the menu-item.
Returns:
the created JMenuItem.

addToMenu

public static javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu,
                                              java.util.HashMap uiMap,
                                              java.lang.String id,
                                              Command command,
                                              java.lang.String iconurl,
                                              java.lang.Class resourceClass,
                                              UIManager uiManager)
Creates a menu item and adds it to the specified menu. The given action is assinged to the item. The id and the uimap reference are used to determine the text string for the menu item.

Parameters:
menu - the menu to add the new MenuItem to.
uiMap - the uimap for text lookup.
id - the id of the text
command - the command associated with the MenuItem.
iconurl - the url for an icon to assign to the MenuItem.
resourceClass - a class instance to use for loading.
uiManager - the UIManager to use for localized strings.
Returns:
the created JMenuItem.

addToMenu

public static javax.swing.JMenuItem addToMenu(javax.swing.JPopupMenu menu,
                                              java.util.HashMap uiMap,
                                              java.lang.String id,
                                              Command command,
                                              javax.swing.KeyStroke ks,
                                              UIManager uiManager)
Creates a menu item and adds it to the specified menu. The given action is assinged to the item. The id and the uimap reference are used to determine the text string for the menu item.

Parameters:
menu - the menu to add the new MenuItem to.
uiMap - the uimap for text lookup.
id - the id of the text
command - the command associated with the MenuItem.
ks - the keystroke to assign to the MenuItem.
uiManager - the UIManager to use for localized strings.
Returns:
the created JMenuItem.

addToMenu

public static javax.swing.JMenuItem addToMenu(javax.swing.JPopupMenu menu,
                                              java.util.HashMap uiMap,
                                              java.lang.String id,
                                              Command command,
                                              javax.swing.KeyStroke ks,
                                              java.lang.String iconurl,
                                              java.lang.Class resourceClass,
                                              UIManager uiManager)
Creates a menu item and adds it to the specified menu. The given action is assinged to the item. The id and the uimap reference are used to determine the text string for the menu item.

Parameters:
menu - the menu to add the new MenuItem to.
uiMap - the uimap for text lookup.
id - the id of the text
command - the command associated with the MenuItem.
ks - the keystroke to assign to the MenuItem.
iconurl - the url for an icon to assign to the MenuItem.
resourceClass - a class instance to use for loading.
uiManager - the UIManager to use for localized strings.
Returns:
the created JMenuItem.

addToMenu

public static javax.swing.JMenuItem addToMenu(javax.swing.JPopupMenu menu,
                                              java.util.HashMap uiMap,
                                              java.lang.String id,
                                              Command command,
                                              javax.swing.KeyStroke ks,
                                              java.lang.String iconurl,
                                              java.lang.String rollovericonurl,
                                              java.lang.Class resourceClass,
                                              UIManager uiManager)
Creates a menu item and adds it to the specified menu. The given action is assinged to the item. The id and the uimap reference are used to determine the text string for the menu item. NOTE: Due to various bugs in several jdk versions the rollover feature has been disabled.

Parameters:
menu - the menu to add the new MenuItem to.
uiMap - the uimap for text lookup.
id - the id of the text
command - the command associated with the MenuItem.
ks - the keystroke to assign to the MenuItem.
iconurl - the url for an icon to assign to the MenuItem.
rollovericonurl - url of the rollover icon.
resourceClass - a class instance to use for loading.
uiManager - the UIManager to use for localized strings.
Returns:
the created JMenuItem.

addToMenu

public static javax.swing.JMenuItem addToMenu(javax.swing.JPopupMenu menu,
                                              java.util.HashMap uiMap,
                                              java.lang.String id,
                                              Command command,
                                              UIManager uiManager)
Creates a menu item and adds it to the specified menu. The given action is assinged to the item. The id and the uimap reference are used to determine the text string for the menu item.

Parameters:
menu - the menu to add the new MenuItem to.
uiMap - the uimap for text lookup. (optional)
id - the id of the text
command - the command associated with the MenuItem.
uiManager - the UIManager to use for localized strings.
Returns:
the created JMenuItem.

addToMenu

public static javax.swing.JMenuItem addToMenu(javax.swing.JPopupMenu menu,
                                              java.util.HashMap uiMap,
                                              java.lang.String id,
                                              Command command,
                                              java.lang.String iconurl,
                                              java.lang.Class resourceClass,
                                              UIManager uiManager)
Creates a menu item and adds it to the specified menu. The given action is assinged to the item. The id and the uimap reference are used to determine the text string for the menu item.

Parameters:
menu - the menu to add the new MenuItem to.
uiMap - the uimap for text lookup.
id - the id of the text
command - the command associated with the MenuItem.
iconurl - the url for an icon to assign to the MenuItem.
resourceClass - a class instance to use for loading.
uiManager - the UIManager to use for localized strings.
Returns:
the created JMenuItem.

getResourceImage

public static final java.awt.Image getResourceImage(java.lang.String iconpath,
                                                    java.lang.Class resourceclass)
Loads an icon manually, without URL resolving. This might help if DNS resolving is involved in applets. This version is not dependent on a component, but should not be used, unless inevitable. It will block with semi-active waiting (it sleeps but will effectively block the current thread until image loading is complete).

Parameters:
iconpath - the path relative to the class resource
resourceclass - the class to use as base for the iconpath.
Returns:
the loaded Image.

getResourceImage

public static final java.awt.Image getResourceImage(java.lang.String iconpath,
                                                    java.lang.Class resourceclass,
                                                    java.awt.Component component,
                                                    boolean trackResource)
Loads an icon manually, without URL resolving. This might help if DNS resolving is involved in applets.

Parameters:
iconpath - ToolBarthe path relative to the class resource
resourceclass - the class to use as base for the iconpath.
component - the component that acts as ImageObserver for the mediatracker.
trackResource - if set to true a MediaTracker will be used to track the loading of the resource.
Returns:
the loaded Image.

getResourceIcon

public static final Icon getResourceIcon(java.lang.String iconurl,
                                         java.lang.Class resourceclass,
                                         java.awt.Component component,
                                         boolean trackResource)
Loads an icon.

Parameters:
iconurl - the path relative to the class resource
resourceclass - the resourceclass to use as base for the iconpath.
component - the component that acts as imageobserver for the mediatracker.
trackResource - whether to use media-tracking or not.
Returns:
the loaded Icon.

addToToolBar

public static javax.swing.AbstractButton addToToolBar(UIManager uiManager,
                                                      javax.swing.JToolBar toolbar,
                                                      Command command,
                                                      java.lang.String iconurl,
                                                      java.lang.Class resourceClass)
Method addToToolbar adds a given command as item to the given ToolBar. The clue is, that the NAME property of the action is cleared, so no text is shown in the ToolBar. Instead an Icon is set, to identify the command. The name of the given command is used as tooltip for the resulting button.

Parameters:
uiManager - the UIManagerto use.
toolbar - the ToolBar reference.
command - the command to use.
iconurl - the icon to use.
resourceClass - the resource reference class.
Returns:
The button created by the JToolbar.add

addToToolBar

public static javax.swing.AbstractButton addToToolBar(UIManager uiManager,
                                                      javax.swing.JToolBar toolbar,
                                                      Command command,
                                                      Icon icon)
Method addToToolbar adds a given command as item to the given toolbar. The clue is, that the NAME property of the action is cleared, so no text is shown in the toolbar. Instead an Icon is set, to identify the command. The name of the given command is used as tooltip for the resulting button.

Parameters:
uiManager - the UIManagerto use.
toolbar - the toolbar reference.
command - the command to use.
icon - the icon to use.
Returns:
JButton The button created by the JToolbar.add

addToToolBar

public static javax.swing.AbstractButton addToToolBar(UIManager uiManager,
                                                      javax.swing.JToolBar toolbar,
                                                      Command command,
                                                      java.lang.String iconurl,
                                                      java.lang.String deficonurl,
                                                      java.lang.Class resourceClass)
Method addToToolbar adds a given command as item to the given toolbar. The clue is, that the NAME property of the action is cleared, so no text is shown in the toolbar. Instead an Icon is set, to identify the command. The name of the given command is used as tooltip for the resulting button.

Parameters:
uiManager - the UIManagerto use.
toolbar - the toolbar reference.
command - the command to use.
iconurl - the icon to use.
deficonurl - the icon to use in windows look and feel.
resourceClass - the resource reference class.
Returns:
The button created by the JToolbar.add

isTensegrityLookAndFeel

public static boolean isTensegrityLookAndFeel()
Checks whether the current look and feel is the tensegrity look and feel or not

Returns:
True, if the current look and feel is the tensegrity look and feel

addToToolBarToggleButton

public static javax.swing.JToggleButton addToToolBarToggleButton(UIManager uiManager,
                                                                 javax.swing.JToolBar toolbar,
                                                                 Command command,
                                                                 java.lang.String iconurl,
                                                                 java.lang.Class resourceClass)
Adds a new togglebutton to the given toolbar.

Parameters:
uiManager - the UIManagerto use.
toolbar - the toolbar reference.
command - the command to use.
resourceClass - class use to load the images.
Returns:
the newly added togglebutton.
See Also:
addToToolBarToggleButton(UIManager, JToolBar, Command, String, String, Class, int)

addToToolBarToggleButton

public static javax.swing.JToggleButton addToToolBarToggleButton(UIManager uiManager,
                                                                 javax.swing.JToolBar toolbar,
                                                                 Command command,
                                                                 java.lang.String iconurl,
                                                                 java.lang.String iconurlToggled,
                                                                 java.lang.Class resourceClass)
Adds a new togglebutton to the given toolbar.

Parameters:
uiManager - the UIManagerto use.
toolbar - the toolbar reference.
command - the command to use.
iconurlToggled - icon to use when toggled.
resourceClass - class use to load the images.
Returns:
the newly added togglebutton.
See Also:
addToToolBarToggleButton(UIManager, JToolBar, Command, String, String, Class, int)

addToToolBarToggleButton

public static javax.swing.JToggleButton addToToolBarToggleButton(UIManager uiManager,
                                                                 javax.swing.JToolBar toolbar,
                                                                 Command command,
                                                                 java.lang.String iconurl,
                                                                 java.lang.String iconurlToggled,
                                                                 java.lang.Class resourceClass,
                                                                 int index)
Method addToToolbar inserts a given command as item at a specific index of the toolbar. And index of -1 will append the item to the end of the existing components. The clue is, that the NAME property of the action is cleared, so no text is shown in the toolbar. Instead an Icon is set, to identify the command. The name of the given command is used as tooltip for the resulting button.

Parameters:
uiManager - required UIManager instance to obtain localized strings.
toolbar - target Toolbar instance to add to.
command - the command to be executed when user selects the resulting button.
iconurl - url to the icon, used as image for the button.
iconurlToggled - url to the icon, used as image when toggled.
resourceClass - class instance to load the icons with.
index - the index to insert the element to. Pass -1 to append the item to the end of the toolbar compoents.
Returns:
the button instance which has been added to the toolbar.

addToToolBarToggleButton

public static javax.swing.JToggleButton addToToolBarToggleButton(UIManager uiManager,
                                                                 javax.swing.JToolBar toolbar,
                                                                 Command command,
                                                                 Icon icon,
                                                                 Icon iconToggled,
                                                                 int index)
Method addToToolbar inserts a given command as item at a specific index of the toolbar. And index of -1 will append the item to the end of the existing components. The clue is, that the NAME property of the action is cleared, so no text is shown in the toolbar. Instead an Icon is set, to identify the command. The name of the given command is used as tooltip for the resulting button.

Parameters:
uiManager - required UIManager instance to obtain localized strings.
toolbar - target Toolbar instance to add to.
command - the command to be executed when user selects the resulting button.
icon - used as image for the button.
iconToggled - url to the icon, used as image when toggled.
index - the index to insert the element to. Pass -1 to append the item to the end of the toolbar compoents.
Returns:
the button instance which has been added to the toolbar.

createToggleButton

public static javax.swing.JToggleButton createToggleButton(javax.swing.AbstractAction action,
                                                           ToggleCommand command)
Creates a toggle button, that changes its state according to the state of the togglecommand.

Parameters:
action - The action for the command
command - The toggle command for this toggle button
Returns:
The created toggle button

unregisterMenu

public static void unregisterMenu(javax.swing.JPopupMenu menu,
                                  java.util.HashMap uiMap)
VIP method to unregister a menu from the uimap. Otherwise the references to the components remain in the uimap and will be a garbage collection killer. So before loosing reference to the menu elsewhere, invoke this method

Parameters:
menu - the menu to remove from the uimap
uiMap - the target uiMap to clean up.

unregisterMenu

public static void unregisterMenu(javax.swing.JMenu menu,
                                  java.util.HashMap uiMap)
VIP method to unregister a menu from the uimap. Otherwise the references to the components remain in the uimap and will be a garbage collection killer. So before loosing reference to the menu elsewhere, invoke this method

Parameters:
menu - the menu to remove from the uimap
uiMap - the target uiMap to clean up.

addComponent

public static void addComponent(java.awt.Container container,
                                java.awt.Component component,
                                int fill,
                                int gX,
                                int gY,
                                int gW,
                                int gH,
                                double wX,
                                double wY)
Adds a component to the container which must have gridbag layout.

Parameters:
container - the container to add to
component - the component to add to
fill - gridbad constraint
gX - gridbad constraint
gY - gridbad constraint
gW - gridbad constraint
gH - gridbad constraint
wX - gridbad constraint
wY - gridbad constraint

addComponent

public static void addComponent(java.awt.Container container,
                                java.awt.Component component,
                                int fill,
                                int gX,
                                int gY,
                                int gW,
                                int gH,
                                double wX,
                                double wY,
                                java.awt.Insets insets)
Adds a component to the container which must have gridbag layout.

Parameters:
container - the container to add to
component - the component to add to
fill - gridbad constraint
gX - gridbad constraint
gY - gridbad constraint
gW - gridbad constraint
gH - gridbad constraint
wX - gridbad constraint
wY - gridbad constraint
insets - the insets

createTitleFrameBorder

public static final javax.swing.border.Border createTitleFrameBorder(java.lang.String title,
                                                                     int top,
                                                                     int left,
                                                                     int bottom,
                                                                     int right)
Method createTitleFrameBorder creates a compound border consisting of 3 Borders: A titled border with default text alignment and font, an etched border for grouping effect and an emptyborder to have some insets.

Parameters:
title - Title as string of your border.
top - space in pixels you want to have top.
left - space in pixels you want to have left.
bottom - space in pixels you want to have bottom.
right - space in pixels you want to have right.
Returns:
Border the compound border.

dumpComponentTree

public static final void dumpComponentTree(java.awt.Component component)
Dumps the swing component tree starting at the given root component.

Parameters:
component - the root of the component tree to dump.

showDialog

public static void showDialog(java.awt.Window dialog)
Shows a dialog in the center.

Parameters:
dialog - the dialog to show.

showDialog

public static void showDialog(java.awt.Dialog dialog)
Shows a dialog in the center.

Parameters:
dialog - the dialog to show.

showDialog

public static final void showDialog(java.awt.Window dialog,
                                    int horizontalPositionHint,
                                    int verticalPositionHint)
Shows a dialog at the given position which is specified by the hints.

Parameters:
dialog - the dialog to show.
horizontalPositionHint - one of the positionhints defined in this class.
verticalPositionHint - one of the positionhints defined in this class.

showDialog

public static final void showDialog(java.awt.Window dialog,
                                    int horizontalPositionHint,
                                    int verticalPositionHint,
                                    boolean considerMaximumWindowSize)
Shows a dialog at the given position which is specified by the hints.

Parameters:
dialog - the dialog to show.
horizontalPositionHint - one of the positionhints defined in this class.
verticalPositionHint - one of the positionhints defined in this class.
considerMaximumWindowSize - if true, the window will be positioned in the available space instead of the complete screen size

setDialogPosition

public static void setDialogPosition(java.awt.Window dialog,
                                     int horizontalPositionHint,
                                     int verticalPositionHint)
Sets the position of the window according to the position hints

Parameters:
dialog - the dialog to show.
horizontalPositionHint - one of the positionhints defined in this class.
verticalPositionHint - one of the positionhints defined in this class.

setDialogPosition

public static void setDialogPosition(java.awt.Window dialog,
                                     int horizontalPositionHint,
                                     int verticalPositionHint,
                                     boolean considerMaximumWindowSize)
Sets the position of the window according to the position hints

Parameters:
dialog - the dialog to show.
horizontalPositionHint - one of the positionhints defined in this class.
verticalPositionHint - one of the positionhints defined in this class.
considerMaximumWindowSize - if true, the window will be positioned in the available space instead of the complete screen size

showFrame

public static final void showFrame(java.awt.Frame frame,
                                   int horizontalPositionHint,
                                   int verticalPositionHint)
Shows a dialog at the given position which is specified by the hints.

Parameters:
horizontalPositionHint - one of the positionhints defined in this class.
verticalPositionHint - one of the positionhints defined in this class.

showConfirmDialog

public static final boolean showConfirmDialog(java.awt.Component parent,
                                              java.lang.String text,
                                              java.lang.String title,
                                              UIManager uiManager)
Shows a confirm dialog, return true if the user confirmed.

Parameters:
parent - the parent of the component.
text - the text to display.
title - the title string of the dialog window.
uiManager - The uiManager to resolve text resources (buttons)
Returns:
true if the user confirmed.

showConfirmDialog

public static final boolean showConfirmDialog(java.awt.Component parent,
                                              java.lang.String text,
                                              java.lang.String title)
Shows a confirm dialog, return true if the user confirmed.

Parameters:
parent - the parent of the component.
text - the text to display.
title - the title string of the dialog window.
Returns:
true if the user confirmed.

showConfirmDialog

public static final boolean showConfirmDialog(java.awt.Component parent,
                                              java.lang.String text,
                                              java.lang.String title,
                                              int messageType)
Shows a confirm dialog, return true if the user confirmed.

Parameters:
parent - the parent of the component.
text - the text to display.
title - the title string of the dialog window.
messageType - the message type of the confirmation dialog
Returns:
true if the user confirmed.

showConfirmDialogWithCancel

public static final int showConfirmDialogWithCancel(java.awt.Component parent,
                                                    java.lang.String text,
                                                    java.lang.String title,
                                                    UIManager uiManager)
Shows a confirm dialog, return user decision.

Parameters:
parent - the parent of the component.
text - the text to display.
title - the title string of the dialog window.
uiManager - The uiManager to resolve text resources (buttons)
Returns:
the user decision using one of the constants of JOptionPane

showConfirmDialogWithCancel

public static final int showConfirmDialogWithCancel(java.awt.Component parent,
                                                    java.lang.String text,
                                                    java.lang.String title,
                                                    UIManager uiManager,
                                                    int messageType)
Shows a confirm dialog, return user decision.

Parameters:
parent - the parent of the component.
text - the text to display.
title - the title string of the dialog window.
uiManager - The uiManager to resolve text resources (buttons)
messageType - the message type of the confirmation dialog
Returns:
the user decision using one of the constants of JOptionPane

showConfirmDialogWithCancel

public static final int showConfirmDialogWithCancel(java.awt.Component parent,
                                                    java.lang.String text,
                                                    java.lang.String title)
Shows a confirm dialog, return user decision.

Parameters:
parent - the parent of the component.
text - the text to display.
title - the title string of the dialog window.
Returns:
the user decision using one of the constants of JOptionPane

saveImageAsBMP

public static final boolean saveImageAsBMP(java.awt.image.BufferedImage image,
                                           java.io.File file)
                                    throws java.lang.Exception
This method will save the given BufferedImageinstance and will save it to the specified file in 24bitplane uncompressed mode.

Parameters:
image - the image to save.
file - the file where to save.
Returns:
True, if the image has been written successfully
Throws:
exception - arbitrary exception if something goes wrong during saving.
java.lang.Exception

saveImageAsBMP

public static final boolean saveImageAsBMP(java.awt.image.BufferedImage image,
                                           java.io.OutputStream os)
                                    throws java.lang.Exception
This method will save the given BufferedImageinstance and will save it to the specified output stream in 24bitplane uncompressed mode.

Parameters:
image - the image to save.
os - the output where to save.
Throws:
java.lang.Exception - arbitrary exception if something goes wrong during saving.

saveImageAsJPEG

public static boolean saveImageAsJPEG(java.awt.image.BufferedImage image,
                                      java.io.File file,
                                      float quality,
                                      boolean forceBaseline)
Saves the given image in File file using JPEG -encoding.

Parameters:
image - the image to save.
file - the file in which to save.
quality - a value between 0.0 (low quality) and 1.0 (high quality)
forceBaseline - force baseline quantization table
Returns:
true, if saving was successful.

saveImageAsJPEG

public static boolean saveImageAsJPEG(java.awt.image.BufferedImage image,
                                      java.io.OutputStream stream,
                                      float quality,
                                      boolean forceBaseline)
Saves the given image in File file using JPEG -encoding.
Notice: Only works with JDK1.4+.

Parameters:
image - the image to save.
stream - the stream to save to.
quality - a value between 0.0 (low quality) and 1.0 (high quality)
forceBaseline - force baseline quantization table
Returns:
true, if saving was successful.

saveImageAsGIF

public static boolean saveImageAsGIF(java.awt.image.BufferedImage image,
                                     java.io.File file)
Saves the given image in File file using GIF -encoding.
Notice: Only works with JDK1.4+.

Parameters:
image - the image to save.
file - the file in which to save.
Returns:
true, if saving was successful.

saveImageAsPNG

public static boolean saveImageAsPNG(java.awt.image.RenderedImage image,
                                     java.io.File file)
Saves the given image in File file using GIF -encoding.
Notice: Only works with JDK1.4+.

Parameters:
image - the image to save.
file - the location to save the image to.
Returns:
true, if saving was successful.

saveImageAsPNG

public static boolean saveImageAsPNG(java.awt.image.RenderedImage image,
                                     java.io.OutputStream os)
This method basically uses the #saveImagesAs(String, RenderedImage, OutputStream)to save the given RenderedImage as PNG.

Parameters:
image - the RenderedImage instance to save.
os - the Stream to write the png to.
Returns:
true, to indicate a successful storage.

canWriteFormat

public static boolean canWriteFormat(java.lang.String formatName)
Returns true if the specified format name can be written

Parameters:
formatName - the name of the format, for example gif.
Returns:
true iff the format can be written.

runningJDK1_4

public static boolean runningJDK1_4()

paintClosingLine

public static final void paintClosingLine(java.awt.Graphics g,
                                          java.awt.Dimension d)
Paints a closing line at the bottom of the specified Dimension.

Parameters:
g - Graphicsto paint into.
d - the dimensions of the painting area.

paintClosingLines

public static final void paintClosingLines(java.awt.Graphics g,
                                           java.awt.Dimension d)
Paints two closing lines at the bottom of the specified Dimension.

Parameters:
g - Graphicsto paint into.
d - the dimensions of the painting area.

alignMenuItems

public static void alignMenuItems(javax.swing.JComponent menu)
This method aligns all MenuElements of the given Menu Component evenly according to a "normal" MenuItem with an Icon. MenuItems without an icon, will get a proper border to align them to the icon-items. Same goes out for Check- and RadioMenuItems. If the current element in the loop is again a Menu or SwingPopupMenu, this method will recurse.

Parameters:
menu - a JComponent of type MenuElement.

setPopupMenu

public static void setPopupMenu(javax.swing.MenuElement popup)

getPopupMenu

public static javax.swing.MenuElement getPopupMenu()

getMaximumWindowBounds

public static java.awt.Rectangle getMaximumWindowBounds()
Returns the maximum rectangle that can be used for windows

Returns:
the maximum rectangle that can be used for windows

requestFocus

public static void requestFocus(java.awt.Component comp)
Requests the focus for the given component.

Parameters:
comp - The component to request focus for

getUIColor

public static java.awt.Color getUIColor(java.lang.Object key)
Returns the color with the given key from the current look and feel or a defaultColor if the entry does not exist. Should be used instead of UIManager.getColor(), because some look and feels might not support all entries. The defaultcolor is taken from a map of defaults that equal the entries of the windows look and feel in JRE 1.5. If the key is not part of the defaults, white is returned.

Parameters:
key - The key of the color to retrieve
Returns:
the color with the given key from the current look and feel or the defaultColor if the entry does not exist.

getUIColor

public static java.awt.Color getUIColor(java.lang.Object key,
                                        java.awt.Color defaultColor)
Returns the color with the given key from the current look and feel or the defaultColor if the entry does not exist. Should be used instead of UIManager.getColor(), because some look and feels might not support all entries.

Parameters:
key - The key of the color to retrieve
defaultColor - The default color to use if the entry does not exist
Returns:
the color with the given key from the current look and feel or the defaultColor if the entry does not exist.

drawString

public static void drawString(javax.swing.JComponent comp,
                              java.awt.Graphics2D g2d,
                              java.lang.String str)
Draws the given string antialiased and centered into the graphics. Uses the insets of the component to determine the available size for the text and decreases the font size until the text fits into the component.

Parameters:
comp - The component the graphics belongs to
g2d - The graphics to draw into
str - The string to draw

drawString

public static void drawString(javax.swing.JComponent comp,
                              java.awt.Graphics2D g2d,
                              java.lang.String str,
                              java.awt.Insets additionalInsets)
Draws the given string antialiased and centered into the graphics. Uses the insets of the component to determine the available size for the text and decreases the font size until the text fits into the component.

Parameters:
comp - The component the graphics belongs to
g2d - The graphics to draw into
str - The string to draw
additionalInsets - Use this to reduce the available space and offset the text

updateComponentTreeUI

public static void updateComponentTreeUI(java.awt.Component c)
A simple minded look and feel change: ask each node in the tree to updateUI() -- that is, to initialize its UI property with the current look and feel. This is a copy of the SwingUtilities.updateComponentTreeUI(java.awt.Component) method including a fix for JToolBars, so that children are processed before the parent.

Parameters:
c - The root of the component tree

doWhenVisible

public static final void doWhenVisible(java.awt.Component component,
                                       java.lang.Runnable runnable)
Runs the Runnable when the given component got a valid size.

Parameters:
component - The component to listen to
runnable - The runnable to start

busyStart

public static void busyStart(java.awt.Component busyComponent)
Sets the busy cursor on the given component. Increments a counter that stores the busy state of the component, so recursive calls to busyStart() and busyEnd() work as expected. Make sure you call busyEnd() in a finally block afterwards!

Parameters:
busyComponent - The component to set the cursor to

busyEnd

public static void busyEnd(java.awt.Component busyComponent)
Decreases the busy counter of the given component and sets the default cursor, if the counter reaches 0. Make sure you call this method after every busyStart() in a finally block!

Parameters:
busyComponent - The component to set the cursor to


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.