QJCC homepage

biz.chitec.quarterback.swing
Class TOM

java.lang.Object
  extended bybiz.chitec.quarterback.swing.TOM

public class TOM
extends java.lang.Object

ToolTip'd Object Maker - create Swing compenents with ToolTips conveniently. Creates Swing components using the given resourcename and add tool tip to it using a resource named given-name-plus-".tip". Furthermore, sets mnemonics (when available) using a resource named given-name-plus-".mnem".

The component can also be given an icon which is displayed appropriately. The icon is expected to be in a separate file whose name is given in a resource named given-name-plus-".iconfile".

Version:
$Id: 6ecb7c81bcb41c4df4a5d71e06a38d2599641533 $
Author:
Dirk Hillbrecht 1997-2000, chitec/Dirk Hillbrecht 2000. Distributed under the terms of the GNU LGPL.

Field Summary
private static java.beans.PropertyChangeListener componentlabelenabler
          Internally used property listener which is put onto labelled JComponents in makeLinkedJLabel(ResourceBundle, String, Component).
private static java.util.Map componentlabels
          Map to store labels in by their component.
private static java.util.Map componentresnames
          Map to store the I18N keys for several components.
private static java.util.regex.Pattern insetspattern
           
 
Constructor Summary
private TOM()
          Private constructor as this class is completely static.
 
Method Summary
static javax.swing.JTabbedPane addTabbedPane(java.util.ResourceBundle rb, javax.swing.JTabbedPane jtp, java.awt.Component co, java.lang.String name)
          Adds a tab to a JTabbedPane.
static void defaultLocaleChanged(java.awt.Component c)
          Notifies all non-locale-specific bundles still in use about the change of the default locale and relabels the given component
private static java.lang.Object[] getStringIconHelpid(java.util.ResourceBundle rb, java.lang.String resname)
          Common method for obtaining name and icon.
static javax.swing.border.Border getTitledBorder(java.util.ResourceBundle rb, java.lang.String resname)
          Return a titled border with default etched lines.
static javax.swing.border.Border getTitledBorder(java.util.ResourceBundle rb, java.lang.String resname, javax.swing.border.Border otherborder)
          Return a titled border with default given other lines.
static javax.swing.Action makeAction(java.util.ResourceBundle rb, java.lang.String resname, javax.swing.Action action)
          equips an Action object with everything needed.
static javax.swing.AbstractButton makeAnyButton(java.util.ResourceBundle rb, java.lang.String resname, javax.swing.AbstractButton b)
          Equips any subclass of AbstractButton with text, icon etc from the resources.
static javax.swing.JButton makeJButton(java.util.ResourceBundle rb, java.lang.String resname)
          Delivers a JButton with text, icon etc from the resources.
static javax.swing.JButton makeJButton(java.util.ResourceBundle rb, java.lang.String resname, javax.swing.JButton b)
          Equips an already existing JButton with text, icon etc from the resources.
static javax.swing.JCheckBox makeJCheckBox(java.util.ResourceBundle rb, java.lang.String resname)
          delivers a check box with tip and mnemonic
static javax.swing.JFrame makeJFrame(java.util.ResourceBundle rb, java.lang.String resname)
          Creates a new JFrame with title and frame icon set.
static javax.swing.JFrame makeJFrame(java.util.ResourceBundle rb, java.lang.String resname, javax.swing.JFrame theframe)
          Equips an already existing JFrame with title and frame icon.
static javax.swing.JInternalFrame makeJInternalFrame(java.util.ResourceBundle rb, java.lang.String resname)
          Creates a new JInternalFrame with title and frame icon set.
static javax.swing.JInternalFrame makeJInternalFrame(java.util.ResourceBundle rb, java.lang.String resname, javax.swing.JInternalFrame theframe)
          Equips an already existing JInternalFrame with title and frame icon.
static javax.swing.JLabel makeJLabel(java.util.ResourceBundle rb, java.lang.String resname)
          delivers a label with a tip and a mnemonic when available.
static javax.swing.JMenu makeJMenu(java.util.ResourceBundle rb, java.lang.String resname)
          Delivers an empty menu with tip and mnemonic
static javax.swing.JMenuItem makeJMenuItem(java.util.ResourceBundle rb, java.lang.String resname)
          Delivers an empty menu with tip and mnemonic
static javax.swing.JMenuItem makeJMenuItem(java.util.ResourceBundle rb, java.lang.String resname, javax.swing.JMenuItem jmi)
          Delivers an empty menu with tip and mnemonic
static javax.swing.JRadioButton makeJRadioButton(java.util.ResourceBundle rb, java.lang.String resname)
          delivers a radio button with tip and mnemonic
static javax.swing.JLabel makeLinkedJLabel(java.util.ResourceBundle rb, java.lang.String resname, java.awt.Component lc)
          Delivers a label with a tip and a mnemonic when available and a Component is passed.
static javax.swing.JLabel makeLinkedJLabel(java.lang.String labelstr, java.awt.Component lc)
          Delivers a label with the given String and a Component is passed.
private static void relabel(java.lang.Object c, java.util.ResourceBundle rb)
          Change the labels of the standard GUI elements after the locale has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

componentlabels

private static java.util.Map componentlabels
Map to store labels in by their component.


componentresnames

private static java.util.Map componentresnames
Map to store the I18N keys for several components.


insetspattern

private static java.util.regex.Pattern insetspattern

componentlabelenabler

private static java.beans.PropertyChangeListener componentlabelenabler
Internally used property listener which is put onto labelled JComponents in makeLinkedJLabel(ResourceBundle, String, Component). It listenes on the "enabled" property and if it changes, it sets the label's enabled state to be the same as the component's enabled state.

Constructor Detail

TOM

private TOM()
Private constructor as this class is completely static.

Method Detail

getStringIconHelpid

private static java.lang.Object[] getStringIconHelpid(java.util.ResourceBundle rb,
                                                      java.lang.String resname)
Common method for obtaining name and icon.


makeAction

public static javax.swing.Action makeAction(java.util.ResourceBundle rb,
                                            java.lang.String resname,
                                            javax.swing.Action action)
equips an Action object with everything needed.


makeJButton

public static javax.swing.JButton makeJButton(java.util.ResourceBundle rb,
                                              java.lang.String resname)
Delivers a JButton with text, icon etc from the resources. The resourcename is taken as base for several markup elements of the button. All of them may be non-existant:

Parameters:
rb - ResourceBundle to read the data from
resname - Base name of the resource
Returns:
Equipped JButton.

makeJButton

public static javax.swing.JButton makeJButton(java.util.ResourceBundle rb,
                                              java.lang.String resname,
                                              javax.swing.JButton b)
Equips an already existing JButton with text, icon etc from the resources. The resourcename is taken as base for several markup elements of the button. All of them may be non-existant:

Parameters:
rb - ResourceBundle to read the data from
resname - Base name of the resource
b - The button to add the stuff to.
Returns:
Equipped button. Same instance as b.

makeAnyButton

public static javax.swing.AbstractButton makeAnyButton(java.util.ResourceBundle rb,
                                                       java.lang.String resname,
                                                       javax.swing.AbstractButton b)
Equips any subclass of AbstractButton with text, icon etc from the resources. The resourcename is taken as base for several markup elements of the button. All of them may be non-existant:

Parameters:
rb - ResourceBundle to read the data from
resname - Base name of the resource
b - The button to add the stuff to.
Returns:
Equipped button. Same instance as b.

makeJMenu

public static javax.swing.JMenu makeJMenu(java.util.ResourceBundle rb,
                                          java.lang.String resname)
Delivers an empty menu with tip and mnemonic


makeJMenuItem

public static javax.swing.JMenuItem makeJMenuItem(java.util.ResourceBundle rb,
                                                  java.lang.String resname)
Delivers an empty menu with tip and mnemonic


makeJMenuItem

public static javax.swing.JMenuItem makeJMenuItem(java.util.ResourceBundle rb,
                                                  java.lang.String resname,
                                                  javax.swing.JMenuItem jmi)
Delivers an empty menu with tip and mnemonic


makeJRadioButton

public static javax.swing.JRadioButton makeJRadioButton(java.util.ResourceBundle rb,
                                                        java.lang.String resname)
delivers a radio button with tip and mnemonic


makeJCheckBox

public static javax.swing.JCheckBox makeJCheckBox(java.util.ResourceBundle rb,
                                                  java.lang.String resname)
delivers a check box with tip and mnemonic


makeLinkedJLabel

public static javax.swing.JLabel makeLinkedJLabel(java.util.ResourceBundle rb,
                                                  java.lang.String resname,
                                                  java.awt.Component lc)
Delivers a label with a tip and a mnemonic when available and a Component is passed. The returned label is bound to the given component. Additionally to the focus passing mechanism an event listener is added to the component, if it is a descendant of JComponent: If its enabled state changes, the enabled state of the label changes also. Usually this leads to the label being grayed out in sync with the component.

Parameters:
rb - Resource bundle to read the label information from
resname - Base name of the resources for the label
lc - Component to be labelled.
Returns:
Ready-to-go label for the component.

makeJLabel

public static javax.swing.JLabel makeJLabel(java.util.ResourceBundle rb,
                                            java.lang.String resname)
delivers a label with a tip and a mnemonic when available.


makeLinkedJLabel

public static javax.swing.JLabel makeLinkedJLabel(java.lang.String labelstr,
                                                  java.awt.Component lc)
Delivers a label with the given String and a Component is passed. The returned label is bound to the given component. Additionally to the focus passing mechanism an event listener is added to the component, if it is a descendant of JComponent: If its enabled state changes, the enabled state of the label changes also. Usually this leads to the label being grayed out in sync with the component.

Parameters:
labelstr - String for the labels text
lc - Component to be labelled.
Returns:
Ready-to-go label for the component.

makeJInternalFrame

public static javax.swing.JInternalFrame makeJInternalFrame(java.util.ResourceBundle rb,
                                                            java.lang.String resname,
                                                            javax.swing.JInternalFrame theframe)
Equips an already existing JInternalFrame with title and frame icon.


makeJInternalFrame

public static javax.swing.JInternalFrame makeJInternalFrame(java.util.ResourceBundle rb,
                                                            java.lang.String resname)
Creates a new JInternalFrame with title and frame icon set.


makeJFrame

public static javax.swing.JFrame makeJFrame(java.util.ResourceBundle rb,
                                            java.lang.String resname,
                                            javax.swing.JFrame theframe)
Equips an already existing JFrame with title and frame icon.


makeJFrame

public static javax.swing.JFrame makeJFrame(java.util.ResourceBundle rb,
                                            java.lang.String resname)
Creates a new JFrame with title and frame icon set.


getTitledBorder

public static javax.swing.border.Border getTitledBorder(java.util.ResourceBundle rb,
                                                        java.lang.String resname)
Return a titled border with default etched lines.


getTitledBorder

public static javax.swing.border.Border getTitledBorder(java.util.ResourceBundle rb,
                                                        java.lang.String resname,
                                                        javax.swing.border.Border otherborder)
Return a titled border with default given other lines.


addTabbedPane

public static javax.swing.JTabbedPane addTabbedPane(java.util.ResourceBundle rb,
                                                    javax.swing.JTabbedPane jtp,
                                                    java.awt.Component co,
                                                    java.lang.String name)
Adds a tab to a JTabbedPane. The method supports icons for the tab.

Parameters:
rb - ResourceBundle to load the i18n'd name from.
jtp - Tabbed pane to add element to
co - Component which is added to the tabbed pane.
name - i18n key for the name to put into the tab.
Returns:
The JTabbedPane to which the element has been added (same as jtp parameter)

defaultLocaleChanged

public static void defaultLocaleChanged(java.awt.Component c)
Notifies all non-locale-specific bundles still in use about the change of the default locale and relabels the given component


relabel

private static void relabel(java.lang.Object c,
                            java.util.ResourceBundle rb)
Change the labels of the standard GUI elements after the locale has changed. This method walks recursively through the whole element tree of the user interface. It changes the label of the elements if this is needed.

Parameters:
c - The component to change the data for
rb - The ResourceBundle to use if no more specific bundle is defined.

QJCC homepage