net.sf.jomic.tools
Class UiTools

java.lang.Object
  extended by net.sf.jomic.tools.UiTools

public final class UiTools
extends java.lang.Object

User interface tools.

Author:
Thomas Aglassinger

Field Summary
static int FRAME_INSET
          Inset to use at the border of a JFrame or JDialog.
 
Method Summary
 void addKeyStrokeAction(javax.swing.JComponent component, java.lang.String keyStrokeName, javax.swing.Action action)
           
 void attemptToRemoveActionListener(javax.swing.AbstractButton button, java.awt.event.ActionListener listener)
          Provided that button is not null, remove listener from it.
 void attemptToRemoveDocumentListener(javax.swing.JTextField field, javax.swing.event.DocumentListener listener)
          Provided that field is not null, remove listener from its Document .
 void centerUp(java.awt.Component frame)
          Center frame in upper half of the screen.
 javax.swing.JPanel createDialogMainPanel()
           
 java.awt.Component createRigidAreaBetweenButtons()
          Create ridig area to put "some" space between two buttons in a BoxLayout.
 void fillMnemonics(javax.swing.JMenu menu)
          Set mnemonics in menu depending on the labels of the MenuItems.
 void fillMnemonics(javax.swing.JMenuBar bar)
          Set mnemonics in bar depending on the labels of the Menus and MenuItems.
 java.awt.Cursor getInvisibleCursor()
          Get an invisible Cursor.
 java.lang.String getKeyText(int keyCode)
          Get (English) text for keyboard code.
 void initColumnWidths(javax.swing.JTable table)
          This method picks good column sizes.
static UiTools instance()
           
 java.lang.String keyStrokeToString(javax.swing.KeyStroke keyStroke)
           Get a string that is parseably by KeyStroke.getKeyStroke().
 void removeKeyStroke(javax.swing.JComponent component, javax.swing.KeyStroke[] keyStrokes)
          Remove for a JComponent all keyStrokes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FRAME_INSET

public static final int FRAME_INSET
Inset to use at the border of a JFrame or JDialog.

See Also:
Constant Field Values
Method Detail

getInvisibleCursor

public java.awt.Cursor getInvisibleCursor()
Get an invisible Cursor. (Based on code by R?al Gagnon, see http://www.rgagnon.com/javadetails/java-0440.html for details.


getKeyText

public java.lang.String getKeyText(int keyCode)
Get (English) text for keyboard code.


instance

public static UiTools instance()

addKeyStrokeAction

public void addKeyStrokeAction(javax.swing.JComponent component,
                               java.lang.String keyStrokeName,
                               javax.swing.Action action)

attemptToRemoveActionListener

public void attemptToRemoveActionListener(javax.swing.AbstractButton button,
                                          java.awt.event.ActionListener listener)
Provided that button is not null, remove listener from it.


attemptToRemoveDocumentListener

public void attemptToRemoveDocumentListener(javax.swing.JTextField field,
                                            javax.swing.event.DocumentListener listener)
Provided that field is not null, remove listener from its Document .


centerUp

public void centerUp(java.awt.Component frame)
Center frame in upper half of the screen.


createDialogMainPanel

public javax.swing.JPanel createDialogMainPanel()

createRigidAreaBetweenButtons

public java.awt.Component createRigidAreaBetweenButtons()
Create ridig area to put "some" space between two buttons in a BoxLayout.

See Also:
Box.createRigidArea(java.awt.Dimension)

fillMnemonics

public void fillMnemonics(javax.swing.JMenu menu)
Set mnemonics in menu depending on the labels of the MenuItems.


fillMnemonics

public void fillMnemonics(javax.swing.JMenuBar bar)
Set mnemonics in bar depending on the labels of the Menus and MenuItems.


initColumnWidths

public void initColumnWidths(javax.swing.JTable table)
This method picks good column sizes. If all column heads are wider than the column's cells' contents, then you can just use column.sizeWidthToFit().


keyStrokeToString

public java.lang.String keyStrokeToString(javax.swing.KeyStroke keyStroke)

Get a string that is parseably by KeyStroke.getKeyStroke(). (KeyStroke.toString() does not return such a string.)

However, there is one keystroke that cannot be represented as a string that can be parsed back to a keystroke - a typed space character. In order to bind an action to a typed space character, KeyStroke.getKeyStroke(new Character(' '), 0) needs to be called.

Source: The Java Developers Almanac 1.4 .

See Also:
KeyStroke.getKeyStroke(java.lang.String)

removeKeyStroke

public void removeKeyStroke(javax.swing.JComponent component,
                            javax.swing.KeyStroke[] keyStrokes)
Remove for a JComponent all keyStrokes. Based on a suggestion in a thread in Sun's developer forum.