com.sshtools.ui.swing
Class UIUtil

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

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

Useful UI utilies.

Author:
$Author: david $

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 javax.swing.text.SimpleAttributeSet getDefaultAttributeSet()
           
static java.awt.Image getFrameImage(javax.swing.Icon icon)
           
static java.awt.Image getImage(javax.swing.Icon icon)
           
static java.awt.Image getImage(javax.swing.ImageIcon imageIcon)
           
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 void positionComponent(int p, java.awt.Component c, java.awt.Component o)
           
static void positionComponent(int p, java.awt.Component c, java.awt.Rectangle d)
           
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 java.awt.Image scaleHeight(int height, java.awt.Image image, java.awt.image.ImageObserver observer)
           
static java.awt.Image scaleWidth(int width, java.awt.Image image, java.awt.image.ImageObserver observer)
           
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 void setIconImage(java.awt.Dialog d, java.awt.Image image)
           
static void showErrorMessage(java.awt.Component parent, java.lang.String mesg, java.lang.String title, java.lang.Throwable exception)
          Show an error message with toggable detail
static void showErrorMessage(java.awt.Component parent, java.lang.String mesg, java.lang.String title, java.lang.Throwable exception, boolean appendExceptionMessageToShortMessage)
          Show an error message with toggable detail
static void showErrorMessage(java.awt.Component parent, java.lang.String title, java.lang.Throwable exception)
          Show an error message with detail
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.

Parameters:
character - mnemonic string
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

positionComponent

public static void positionComponent(int p,
                                     java.awt.Component c,
                                     java.awt.Component o)

positionComponent

public static void positionComponent(int p,
                                     java.awt.Component c,
                                     java.awt.Rectangle d)

showErrorMessage

public static void showErrorMessage(java.awt.Component parent,
                                    java.lang.String title,
                                    java.lang.Throwable exception)
Show an error message with detail

Parameters:
parent -
title -
exception -

showErrorMessage

public static void showErrorMessage(java.awt.Component parent,
                                    java.lang.String mesg,
                                    java.lang.String title,
                                    java.lang.Throwable exception)
Show an error message with toggable detail

Parameters:
parent -
mesg -
title -
exception -

showErrorMessage

public static void showErrorMessage(java.awt.Component parent,
                                    java.lang.String mesg,
                                    java.lang.String title,
                                    java.lang.Throwable exception,
                                    boolean appendExceptionMessageToShortMessage)
Show an error message with toggable detail

Parameters:
parent -
mesg -
title -
appenExceptionMessageToShortMessage -
exception -

scaleWidth

public static java.awt.Image scaleWidth(int width,
                                        java.awt.Image image,
                                        java.awt.image.ImageObserver observer)

scaleHeight

public static java.awt.Image scaleHeight(int height,
                                         java.awt.Image image,
                                         java.awt.image.ImageObserver observer)

getDefaultAttributeSet

public static javax.swing.text.SimpleAttributeSet getDefaultAttributeSet()

getImage

public static java.awt.Image getImage(javax.swing.ImageIcon imageIcon)

getImage

public static java.awt.Image getImage(javax.swing.Icon icon)

getFrameImage

public static java.awt.Image getFrameImage(javax.swing.Icon icon)

setIconImage

public static void setIconImage(java.awt.Dialog d,
                                java.awt.Image image)


Copyright © 2003-2009 SSHTOOLS LTD. All Rights Reserved.