com.isti.util.gui
Class GuiUtilFns

java.lang.Object
  extended bycom.isti.util.gui.GuiUtilFns

public class GuiUtilFns
extends java.lang.Object

Class GuiUtilFns defines a set of various static utility methods for use in GUI applications.


Method Summary
static void ensureRowVisible(javax.swing.JTable tableObj, int row)
          Ensures that the specified table row is visible.
static void ensureSelectionVisible(javax.swing.JTable tableObj)
          Ensures that the current table selection is visible.
static int getExtendedFrameState(java.awt.Frame frameObj)
          Returns the "extended" state of the given frame.
static int getFrameMaximizedBothValue()
          Returns the value of Frame.MAXIMIZED_BOTH.
static java.awt.Rectangle getMaximumWindowBounds()
          Returns the maximum bounds for centered windows.
static java.lang.String getSpacerStrForWidth(int widthVal, java.awt.Component compObj)
          Generates a spacer string containing the maximum number of space characters that will fit within the given pixel width, using the given component.
static java.lang.String getSpacerStrForWidth(int widthVal, java.awt.Component compObj, java.awt.Font fontObj)
          Generates a spacer string containing the maximum number of space characters that will fit within the given pixel width, using the given component and font.
static java.lang.String getSpacerStrForWidth(int widthVal, java.awt.Component compObj, java.awt.Font fontObj, int defWidthVal)
          Generates a spacer string containing the maximum number of space characters that will fit within the given pixel width, using the given component and font.
static java.lang.String getSpacerStrForWidth(int widthVal, java.awt.Component compObj, int defWidthVal)
          Generates a spacer string containing the maximum number of space characters that will fit within the given pixel width, using the given component.
static java.lang.String getSpacerStrForWidth(int widthVal, int spaceCharSize)
          Generates a spacer string containing the maximum number of space characters that will fit within the given pixel width.
static int getStringWidth(java.awt.Component compObj, java.awt.Font fontObj, java.lang.String str)
          Returns the width, in pixels, of the given string.
static int getStringWidth(java.awt.Component compObj, java.awt.Font fontObj, java.lang.String str, int defWidthVal)
          Returns the width, in pixels, of the given string.
static int getStringWidth(java.awt.Component compObj, java.lang.String str)
          Returns the width, in pixels, of the given string.
static int getStringWidth(java.awt.Component compObj, java.lang.String str, int defWidthVal)
          Returns the width, in pixels, of the given string.
static int getStringWidth(java.awt.Font fontObj, java.lang.String str)
          Returns the width, in pixels, of the given string.
static int getStringWidth(java.awt.Font fontObj, java.lang.String str, int defWidthVal)
          Returns the width, in pixels, of the given string.
static int getStringWidth(java.lang.String str)
          Returns the width, in pixels, of the given string.
static int getStringWidth(java.lang.String str, int defWidthVal)
          Returns the width, in pixels, of the given string.
static void initColumnSizes(javax.swing.JTable tableObj)
           
static boolean isFrameMaximized(java.awt.Frame frameObj)
          Determines if the given frame is maximized (both horizontally and vertically).
static boolean maximizeFrame(java.awt.Frame frameObj)
          Sets the state of the given frame to "maximized" (both horizontally and vertically).
static void setEmptyJListWidth(javax.swing.JList listObj, int widthVal)
          Sets the fixed cell width that the given 'JList' is to have when its contents are empty.
static boolean setExtendedFrameState(java.awt.Frame frameObj, int stateVal)
          Sets the "extended" state of the given frame.
static void setScrollPaneCentered(javax.swing.JScrollPane paneObj)
          Sets the given scroll-pane to have its scroll-bars centered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

ensureSelectionVisible

public static void ensureSelectionVisible(javax.swing.JTable tableObj)
Ensures that the current table selection is visible.

Parameters:
tableObj - the table object.

ensureRowVisible

public static void ensureRowVisible(javax.swing.JTable tableObj,
                                    int row)
Ensures that the specified table row is visible.

Parameters:
tableObj - the table object.
row - the row index.

getStringWidth

public static int getStringWidth(java.awt.Component compObj,
                                 java.awt.Font fontObj,
                                 java.lang.String str,
                                 int defWidthVal)
Returns the width, in pixels, of the given string.

Parameters:
compObj - the component to use, or null to use a default 'JLabel' object.
fontObj - the font to use, or null to use the font from the given component object.
str - the string to use.
defWidthVal - a default width value to be returned if an error occurs while calculating the width.
Returns:
The width, in pixels, of the given string.

getStringWidth

public static int getStringWidth(java.awt.Component compObj,
                                 java.lang.String str,
                                 int defWidthVal)
Returns the width, in pixels, of the given string. The font from the given component object is used.

Parameters:
compObj - the component to use, or null to use a default 'JLabel' object.
str - the string to use.
defWidthVal - a default width value to be returned if an error occurs while calculating the width.
Returns:
The width, in pixels, of the given string.

getStringWidth

public static int getStringWidth(java.awt.Font fontObj,
                                 java.lang.String str,
                                 int defWidthVal)
Returns the width, in pixels, of the given string. A default 'JLabel' object is used.

Parameters:
fontObj - the font to use, or null to use the font from the given component object.
str - the string to use.
defWidthVal - a default width value to be returned if an error occurs while calculating the width.
Returns:
The width, in pixels, of the given string.

getStringWidth

public static int getStringWidth(java.awt.Component compObj,
                                 java.awt.Font fontObj,
                                 java.lang.String str)
Returns the width, in pixels, of the given string.

Parameters:
compObj - the component to use, or null to use a default 'JLabel' object.
fontObj - the font to use, or null to use the font from the given component object.
str - the string to use.
Returns:
The width, in pixels, of the given string; or 0 if an error occurs.

getStringWidth

public static int getStringWidth(java.awt.Font fontObj,
                                 java.lang.String str)
Returns the width, in pixels, of the given string. A default 'JLabel' object is used.

Parameters:
fontObj - the font to use, or null to use the font from the given component object.
str - the string to use.
Returns:
The width, in pixels, of the given string; or 0 if an error occurs.

getStringWidth

public static int getStringWidth(java.awt.Component compObj,
                                 java.lang.String str)
Returns the width, in pixels, of the given string. The font from the given component object is used.

Parameters:
compObj - the component to use, or null to use a default 'JLabel' object.
str - the string to use.
Returns:
The width, in pixels, of the given string; or 0 if an error occurs.

getStringWidth

public static int getStringWidth(java.lang.String str,
                                 int defWidthVal)
Returns the width, in pixels, of the given string. A default 'JLabel' object and font are used.

Parameters:
str - the string to use.
defWidthVal - a default width value to be returned if an error occurs while calculating the width.
Returns:
The width, in pixels, of the given string.

getStringWidth

public static int getStringWidth(java.lang.String str)
Returns the width, in pixels, of the given string. A default 'JLabel' object and font are used.

Parameters:
str - the string to use.
Returns:
The width, in pixels, of the given string; or 0 if an error occurs.

getSpacerStrForWidth

public static java.lang.String getSpacerStrForWidth(int widthVal,
                                                    int spaceCharSize)
Generates a spacer string containing the maximum number of space characters that will fit within the given pixel width. The size of the space character ('spaceCharSize') may be generated via the 'getStringWidth()' method.

Parameters:
widthVal - the pixel width to use.
spaceCharSize - the size (in pixels) of a space character to use, or 0 to use a default size.
Returns:
A string containing 0 or more space characters.

getSpacerStrForWidth

public static java.lang.String getSpacerStrForWidth(int widthVal,
                                                    java.awt.Component compObj,
                                                    java.awt.Font fontObj,
                                                    int defWidthVal)
Generates a spacer string containing the maximum number of space characters that will fit within the given pixel width, using the given component and font.

Parameters:
widthVal - the pixel width to use.
compObj - the component to use, or null to use a default 'JLabel' object.
fontObj - the font to use, or null to use the font from the given component object.
defWidthVal - a default width value for the size of space character in pixels (used if an error occurs while determining the size).
Returns:
A string containing 0 or more space characters.

getSpacerStrForWidth

public static java.lang.String getSpacerStrForWidth(int widthVal,
                                                    java.awt.Component compObj,
                                                    java.awt.Font fontObj)
Generates a spacer string containing the maximum number of space characters that will fit within the given pixel width, using the given component and font.

Parameters:
widthVal - the pixel width to use.
compObj - the component to use, or null to use a default 'JLabel' object.
fontObj - the font to use, or null to use the font from the given component object.
Returns:
A string containing 0 or more space characters.

getSpacerStrForWidth

public static java.lang.String getSpacerStrForWidth(int widthVal,
                                                    java.awt.Component compObj,
                                                    int defWidthVal)
Generates a spacer string containing the maximum number of space characters that will fit within the given pixel width, using the given component.

Parameters:
widthVal - the pixel width to use.
compObj - the component to use, or null to use a default 'JLabel' object.
defWidthVal - a default width value for the size of space character in pixels (used if an error occurs while determining the size).
Returns:
A string containing 0 or more space characters.

getSpacerStrForWidth

public static java.lang.String getSpacerStrForWidth(int widthVal,
                                                    java.awt.Component compObj)
Generates a spacer string containing the maximum number of space characters that will fit within the given pixel width, using the given component.

Parameters:
widthVal - the pixel width to use.
compObj - the component to use, or null to use a default 'JLabel' object.
Returns:
A string containing 0 or more space characters.

setScrollPaneCentered

public static void setScrollPaneCentered(javax.swing.JScrollPane paneObj)
Sets the given scroll-pane to have its scroll-bars centered. This action is delayed via "SwingUtilities.invokeLater()" to help allow the scroll-pane to get setup.

Parameters:
paneObj - the scroll-pane object to use.

setEmptyJListWidth

public static void setEmptyJListWidth(javax.swing.JList listObj,
                                      int widthVal)
Sets the fixed cell width that the given 'JList' is to have when its contents are empty. This is accomplished via a 'ListDataListener' that is added to the given list's model, which enters the given fixed cell width when the list is empty and enters '-1' (via the 'setFixedCellWidth()' method) when the list contains entries. As such, if a new list model is set for the 'JList' then the listener will no longer operate.

Parameters:
listObj - the 'JList' to use.
widthVal - the width value to use.

getExtendedFrameState

public static int getExtendedFrameState(java.awt.Frame frameObj)
Returns the "extended" state of the given frame. If the frame is "maximized" (both horizontally and vertically) then the following test will be true: (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH This utility method allows program compiled under Java 1.3 to access the Java >=1.4 method 'Frame.getExtendedState()'.

Parameters:
frameObj - 'Frame' object to use.
Returns:
The "extended" state of the given frame.

setExtendedFrameState

public static boolean setExtendedFrameState(java.awt.Frame frameObj,
                                            int stateVal)
Sets the "extended" state of the given frame. This utility method allows program compiled under Java 1.3 to access the Java >=1.4 method 'Frame.setExtendedState()'.

Parameters:
frameObj - 'Frame' object to use.
stateVal - frame-state-bitmap value to use.
Returns:
true if successful; false if not.

initColumnSizes

public static void initColumnSizes(javax.swing.JTable tableObj)

isFrameMaximized

public static boolean isFrameMaximized(java.awt.Frame frameObj)
Determines if the given frame is maximized (both horizontally and vertically).

Parameters:
frameObj - 'Frame' object to use.
Returns:
true if the given frame is maximized; false if not.

maximizeFrame

public static boolean maximizeFrame(java.awt.Frame frameObj)
Sets the state of the given frame to "maximized" (both horizontally and vertically).

Parameters:
frameObj - 'Frame' object to use.
Returns:
true if successful; false if not.

getFrameMaximizedBothValue

public static int getFrameMaximizedBothValue()
Returns the value of Frame.MAXIMIZED_BOTH.

Returns:
The value of Frame.MAXIMIZED_BOTH.

getMaximumWindowBounds

public static java.awt.Rectangle getMaximumWindowBounds()
Returns the maximum bounds for centered windows. These bounds account for objects in the native windowing system such as task bars and menu bars. The returned bounds will reside on a single display with one exception: on multi-screen systems where Windows should be centered across all displays, this method returns the bounds of the entire display area. This utility method allows program compiled under Java 1.3 to access the Java >=1.4 method 'GraphicsEnvironment.getMaximumWindowBounds()'.

Returns:
The maximum bounds for centered windows.