com.sshtools.ui.swing
Class UIUtil

java.lang.Object
  extended bycom.sshtools.ui.swing.UIUtil
All Implemented Interfaces:
javax.swing.SwingConstants

public class UIUtil
extends java.lang.Object
implements javax.swing.SwingConstants

Useful UI utilies.

Version:
$Revision: 1.1 $
Author:
$Author: richard $

Field Summary
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
UIUtil()
           
 
Method Summary
static void jGridBagAdd(javax.swing.JComponent parent, java.awt.Component componentToAdd, java.awt.GridBagConstraints constraints, int pos)
          Add a component to a container that is using a GridBagLayout, together with its constraints and the GridBagConstraints.gridwidth value.
static javax.swing.KeyStroke parseAcceleratorString(java.lang.String string)
          Parse a string in the format of [ALT+|CTRL+|SHIFT+] to create a keystroke.
static java.lang.Integer parseMnemonicString(java.lang.String string)
          Parse a string in the format of [character] to create an Integer that may be used for an action.
static void positionComponent(int p, java.awt.Component c)
          Position a component on the screen (must be a java.awt.Window to be useful)
static java.lang.String rectangleToString(java.awt.Rectangle rectangle)
          Convert a Rectangle object to a comma separated string in the format of x,y,width,height.
static void selectStringInList(java.lang.String string, javax.swing.JComboBox list)
          Select an item in a JComboBox given an items string value
static void selectStringInList(java.lang.String string, javax.swing.JList list)
          Select an item in a JList given an items string value
static java.awt.Rectangle stringToRectangle(java.lang.String string, java.awt.Rectangle defaultValue)
          Convert a string in the format of x,y,width,height in to a Rectangle object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UIUtil

public UIUtil()
Method Detail

selectStringInList

public static void selectStringInList(java.lang.String string,
                                      javax.swing.JList list)
Select an item in a JList given an items string value

Parameters:
string - string to select in list
list - list

selectStringInList

public static void selectStringInList(java.lang.String string,
                                      javax.swing.JComboBox list)
Select an item in a JComboBox given an items string value

Parameters:
string - string to select in list
list - list

stringToRectangle

public static java.awt.Rectangle stringToRectangle(java.lang.String string,
                                                   java.awt.Rectangle defaultValue)
Convert a string in the format of x,y,width,height in to a Rectangle object. Suitable for retrieving rectangles from property files, XML files etc. The supplied default value will be returned if the string is not in the correct format or is null.

Parameters:
string - string in format x,y,width,height
defaultValue - default rectangle
Returns:
rectangle

rectangleToString

public static java.lang.String rectangleToString(java.awt.Rectangle rectangle)
Convert a Rectangle object to a comma separated string in the format of x,y,width,height. Suitable for storing rectangles in property files, XML files etc.

Parameters:
rectangle - rectangle
Returns:
comman separated string x,y,width,height

parseMnemonicString

public static java.lang.Integer parseMnemonicString(java.lang.String string)
Parse a string in the format of [character] to create an Integer that may be used for an action.

Returns:
mnemonic

parseAcceleratorString

public static javax.swing.KeyStroke parseAcceleratorString(java.lang.String string)
Parse a string in the format of [ALT+|CTRL+|SHIFT+] to create a keystroke. This can be used to define accelerators from resource bundles

Parameters:
string - accelerator string
Returns:
keystroke

jGridBagAdd

public static void jGridBagAdd(javax.swing.JComponent parent,
                               java.awt.Component componentToAdd,
                               java.awt.GridBagConstraints constraints,
                               int pos)
Add a component to a container that is using a GridBagLayout, together with its constraints and the GridBagConstraints.gridwidth value.

Parameters:
parent - parent container
componentToAdd - component to add
constraints - contraints
pos - grid width position
Throws:
java.lang.IllegalArgumentException

positionComponent

public static void positionComponent(int p,
                                     java.awt.Component c)
Position a component on the screen (must be a java.awt.Window to be useful)

Parameters:
p - postion from SwingConstants
c - component


Copyright © 2003-2004 3SP LTD. All Rights Reserved.