Holger's
Java API

com.antelmann.util.gui
Class Menus

java.lang.Object
  extended by com.antelmann.util.gui.Menus

public final class Menus
extends Object

Menus provides some convenient menus and dialogs that are potentially useful for any Java Swing Application. If available, it takes advantage of com.incors.plaf.kunststoff.KunststoffLookAndFeel and com.jgoodies.looks.

Author:
Holger Antelmann

Field Summary
static String aboutString
           
static ImageIcon antelmannIcon
           
 
Constructor Summary
Menus()
           
 
Method Summary
static void center(Component c)
          centers the given Component in the middle of the screen
static JMenuItem createAboutBoxMenuItem(Frame parent)
          returns an 'about' menu capable of displaying an Antelmann.com's info box.
static JMenuItem createAboutDialogMenuItem(Frame parent)
          returns an 'about' menu capable of displaying an Antelmann.com's info box.
static JMenuBar createDefaultMenuBar(Frame parent)
          returns a convenient standard JMenuBar to be used with any Frame
static JDialog createDialog(Component parent, String title, boolean modal)
           
static JMenu createLookAndFeelMenu(Frame rootComponent)
          createLookAndFeelMenu() generates a JMenu that lets the user select from different look&feel options.
static char[] enterPassword(Component parent)
          returns null on cancel
static char[] enterPassword(Component parent, String title, Object message, String initialValue)
          returns null on cancel
static char[] enterPassword(Component parent, String title, Object message, String initialValue, ImageIcon icon)
          returns null on cancel; tries to set caps lock to false to avoid common mistakes
static Dialog getDialogForComponent(Component component)
           
static ResourceBundle getLanguage(Locale l)
          returns a newly generated language bundle based on the given locale
static boolean isCapsLockOn()
           
static ResourceBundle language()
          provides access to the Locale specific language used in this package
static void makeCompactSpringGrid(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(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 setCapsLock(boolean flag)
           
static void setLanguage(Locale l)
          allows to change the language at runtime (the default locale is used by default)
static void showAboutBox(Component parent)
          shows a small antelmann.com about dialog
static void showAboutDialog(Component parent)
          shows the standard antelmann.com about dialog with license, version and upgrade button
static void showExceptionDialog(Component parent, Throwable ex)
           
static void showExceptionDialog(Component parent, Throwable ex, Thread t)
           
static void showExceptionDialog(Throwable ex)
           
static void showLicenseDialog(Component parent)
           
static void showPropertiesDialog(String title, Map properties, Component parent, boolean modal)
          Deprecated. use makePropertiesTable with JOptionPane instead
static void showVersionDialog(Component parent)
           
static void showWarning(Component parent, Exception ex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

antelmannIcon

public static final ImageIcon antelmannIcon

aboutString

public static final String aboutString
Constructor Detail

Menus

public Menus()
Method Detail

getLanguage

public static ResourceBundle getLanguage(Locale l)
returns a newly generated language bundle based on the given locale


language

public static ResourceBundle language()
provides access to the Locale specific language used in this package


setLanguage

public static void setLanguage(Locale l)
allows to change the language at runtime (the default locale is used by default)


center

public static void center(Component c)
centers the given Component in the middle of the screen


createDefaultMenuBar

public static JMenuBar createDefaultMenuBar(Frame parent)
returns a convenient standard JMenuBar to be used with any Frame


createLookAndFeelMenu

public static JMenu createLookAndFeelMenu(Frame rootComponent)
createLookAndFeelMenu() generates a JMenu that lets the user select from different look&feel options.

Parameters:
rootComponent - the top component of the GUI tree that needs to be updated

createAboutDialogMenuItem

public static JMenuItem createAboutDialogMenuItem(Frame parent)
returns an 'about' menu capable of displaying an Antelmann.com's info box.

Parameters:
parent - the component over which the modal dialog is to be placed

createAboutBoxMenuItem

public static JMenuItem createAboutBoxMenuItem(Frame parent)
returns an 'about' menu capable of displaying an Antelmann.com's info box.

Parameters:
parent - the component over which the modal dialog is to be placed

showAboutBox

public static void showAboutBox(Component parent)
shows a small antelmann.com about dialog


showAboutDialog

public static void showAboutDialog(Component parent)
shows the standard antelmann.com about dialog with license, version and upgrade button


showVersionDialog

public static void showVersionDialog(Component parent)

showLicenseDialog

public static void showLicenseDialog(Component parent)

showPropertiesDialog

@Deprecated
public static void showPropertiesDialog(String title,
                                                   Map properties,
                                                   Component parent,
                                                   boolean modal)
Deprecated. use makePropertiesTable with JOptionPane instead

shows a JDialog containing a JTable to display the given properties sorted

See Also:
TableUtils.makePropertiesTable(Map, String, String)

showExceptionDialog

public static void showExceptionDialog(Throwable ex)

showExceptionDialog

public static void showExceptionDialog(Component parent,
                                       Throwable ex)

showExceptionDialog

public static void showExceptionDialog(Component parent,
                                       Throwable ex,
                                       Thread t)

showWarning

public static void showWarning(Component parent,
                               Exception ex)

enterPassword

public static char[] enterPassword(Component parent)
returns null on cancel


enterPassword

public static char[] enterPassword(Component parent,
                                   String title,
                                   Object message,
                                   String initialValue)
returns null on cancel


enterPassword

public static char[] enterPassword(Component parent,
                                   String title,
                                   Object message,
                                   String initialValue,
                                   ImageIcon icon)
returns null on cancel; tries to set caps lock to false to avoid common mistakes


createDialog

public static JDialog createDialog(Component parent,
                                   String title,
                                   boolean modal)
See Also:
JOptionPane.createDialog(Component, String)

getDialogForComponent

public static Dialog getDialogForComponent(Component component)

setCapsLock

public static void setCapsLock(boolean flag)
                        throws UnsupportedOperationException
Throws:
UnsupportedOperationException

isCapsLockOn

public static boolean isCapsLockOn()
                            throws UnsupportedOperationException
Throws:
UnsupportedOperationException

makeSpringGrid

public static void makeSpringGrid(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. 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 parent component must be a SpringLayout. The code for this method is based on the turorial from the Sun Java website.

Parameters:
rows - number of rows
cols - number of columns
initialX - x location to start the grid at
initialY - y location to start the grid at
xPad - x padding between cells
yPad - y padding between cells

makeCompactSpringGrid

public static void makeCompactSpringGrid(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. 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 parent component must be a SpringLayout. The code for this method is based on the turorial from the Sun Java website.

Parameters:
rows - number of rows
cols - number of columns
initialX - x location to start the grid at
initialY - y location to start the grid at
xPad - x padding between cells
yPad - y padding between cells


(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads