chemaxon.marvin.util
Class SwingUtil

java.lang.Object
  extended by chemaxon.marvin.util.SwingUtil
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.util.EventListener

public class SwingUtil
extends java.lang.Object
implements java.io.Serializable, java.awt.event.ActionListener

Swing utility functions.

Since:
Marvin 3.3.1, 01/15/2004
Version:
4.1, 01/18/2006
Author:
Peter Csizmadia
See Also:
Serialized Form

Method Summary
 void actionPerformed(java.awt.event.ActionEvent ev)
           
static javax.swing.JMenu createMenu(java.util.ResourceBundle rc, java.lang.String key)
          Utility method to create a menu with a label specified as a resource.
static javax.swing.JMenu createMenu(java.util.ResourceBundle rc, java.lang.String key, boolean mnemo)
          Creates a menu with a label specified as a resource.
static javax.swing.JMenuItem createMenuItem(java.util.ResourceBundle rc, java.lang.String key)
          Creates a menu with a label specified as a resource.
static javax.swing.JMenuItem createMenuItem(java.util.ResourceBundle rc, java.lang.String key, boolean mnemo)
          Creates a menu with a label specified as a resource.
static javax.swing.JMenuItem createMenuItem(java.util.ResourceBundle rc, java.lang.String key, java.lang.Class what, boolean mnemo)
          Creates a menu item with a label specified as a resource.
static javax.swing.JPanel createSubPanel(java.lang.String title)
          Creates a sub-panel with a title.
static java.awt.GridBagConstraints createTopLeftConstraints()
          Creates GridBagConstraints for the top left component.
static void decorateSubPanel(javax.swing.JPanel panel, java.lang.String title)
          Creates border and title for a panel.
static javax.swing.KeyStroke getCommandKeyStroke(int key)
          Gets the command keystroke preferred on the current platform.
static void initAction(javax.swing.Action action, java.util.ResourceBundle rc, java.lang.String key, javax.swing.KeyStroke accel)
          Initializes an action from information in a resource.
static void initButton(javax.swing.AbstractButton b, java.util.ResourceBundle rc, java.lang.String key)
          Utility method to initialize a button from information in a resource.
static void initButton(javax.swing.AbstractButton b, java.util.ResourceBundle rc, java.lang.String key, boolean mnemo)
          Utility method to initialize a button from information in a resource.
static void initCtrlShortcutForMac(javax.swing.JMenuItem mi)
          Makes Mac Command shortcuts work with Ctrl too.
static void initInApplet()
          This method must be called if the JVM runs in an applet.
static java.awt.Color showColorChooserDialog(java.awt.Component component, java.lang.String title, java.awt.Color color, javax.swing.JColorChooser pane)
          Displays a color chooser dialog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

initInApplet

public static void initInApplet()
This method must be called if the JVM runs in an applet. The method call must be placed in the applet's static block.


showColorChooserDialog

public static java.awt.Color showColorChooserDialog(java.awt.Component component,
                                                    java.lang.String title,
                                                    java.awt.Color color,
                                                    javax.swing.JColorChooser pane)
Displays a color chooser dialog.

Parameters:
component - the parent component for the dialog
title - the dialog title
color - the initial color
pane - the color chooser pane
Since:
Marvin 4.1, 01/18/2006

getCommandKeyStroke

public static javax.swing.KeyStroke getCommandKeyStroke(int key)
Gets the command keystroke preferred on the current platform.

Parameters:
key - the key
Returns:
keystroke for the specified key and meta (for Mac) or control (for other platforms)

createMenuItem

public static javax.swing.JMenuItem createMenuItem(java.util.ResourceBundle rc,
                                                   java.lang.String key,
                                                   java.lang.Class what,
                                                   boolean mnemo)
Creates a menu item with a label specified as a resource. If the label string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.

Parameters:
rc - the resources
key - name of the label resource
what - menu item class
mnemo - use mnemonic or not
Returns:
the menu
Since:
Marvin 4.1, 11/10/2005

createMenuItem

public static javax.swing.JMenuItem createMenuItem(java.util.ResourceBundle rc,
                                                   java.lang.String key,
                                                   boolean mnemo)
Creates a menu with a label specified as a resource. If the label string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.

Parameters:
rc - the resources
key - name of the label resource
mnemo - set the mnemonic or not
Returns:
the menu item
Since:
Marvin 4.1, 11/10/2005

createMenuItem

public static javax.swing.JMenuItem createMenuItem(java.util.ResourceBundle rc,
                                                   java.lang.String key)
Creates a menu with a label specified as a resource. If the label string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.

Parameters:
rc - the resources
key - name of the label resource
Returns:
the menu item
Since:
Marvin 4.1, 11/10/2005

createMenu

public static javax.swing.JMenu createMenu(java.util.ResourceBundle rc,
                                           java.lang.String key)
Utility method to create a menu with a label specified as a resource. If the label string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.

Parameters:
rc - the resources
key - name of the label resource
Returns:
the menu

createMenu

public static javax.swing.JMenu createMenu(java.util.ResourceBundle rc,
                                           java.lang.String key,
                                           boolean mnemo)
Creates a menu with a label specified as a resource. If the label string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.

Parameters:
rc - the resources
key - name of the label resource
mnemo - set the mnemonic or not
Returns:
the menu
Since:
Marvin 4.1, 11/10/2005

initButton

public static void initButton(javax.swing.AbstractButton b,
                              java.util.ResourceBundle rc,
                              java.lang.String key)
Utility method to initialize a button from information in a resource. If the resource string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.

Parameters:
b - the button
rc - the resources
key - name of the resource

initButton

public static void initButton(javax.swing.AbstractButton b,
                              java.util.ResourceBundle rc,
                              java.lang.String key,
                              boolean mnemo)
Utility method to initialize a button from information in a resource. If the resource string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.

Parameters:
b - the button
rc - the resources
key - name of the resource
mnemo - set the mnemonic or not

initAction

public static void initAction(javax.swing.Action action,
                              java.util.ResourceBundle rc,
                              java.lang.String key,
                              javax.swing.KeyStroke accel)
Initializes an action from information in a resource. If the resource string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.

Parameters:
action - the action
rc - the resources
key - name of the resource
accel - the accelerator or null

initCtrlShortcutForMac

public static void initCtrlShortcutForMac(javax.swing.JMenuItem mi)
Makes Mac Command shortcuts work with Ctrl too. Workaround for the Command shortcut bug in Safari and other web browsers (Mac OS X). This method should be called after setting the accelerator. It should be called also in the readObject method of the menu item class because the secondary keyboard shortcut is not serialized.

Parameters:
mi - menu item to initialize
Since:
Marvin 3.4, 06/25/2004

decorateSubPanel

public static void decorateSubPanel(javax.swing.JPanel panel,
                                    java.lang.String title)
Creates border and title for a panel.

Parameters:
title - the panel title
Since:
Marvin 4.1, 11/10/2005

createSubPanel

public static javax.swing.JPanel createSubPanel(java.lang.String title)
Creates a sub-panel with a title.

Parameters:
title - the panel title
Returns:
the panel
Since:
Marvin 4.1, 11/10/2005
See Also:
decorateSubPanel(JPanel, String)

createTopLeftConstraints

public static java.awt.GridBagConstraints createTopLeftConstraints()
Creates GridBagConstraints for the top left component.

Returns:
the constraints
Since:
Marvin 4.1, 11/10/2005

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ev)
Specified by:
actionPerformed in interface java.awt.event.ActionListener