VLab Common 1.2

pl.psnc.vlab.util.gui.helper
Class FormHelper

java.lang.Object
  extended by pl.psnc.vlab.util.gui.helper.FormHelper

public abstract class FormHelper
extends java.lang.Object

FormHelper - abstract class defines a set of utility helper methods when dealing with gui.

Author:
Dominik Stoklosa (~osa~)
Email address
osa@man.poznan.pl

Constructor Summary
FormHelper()
           
 
Method Summary
static java.lang.String format(java.lang.Number value)
          Parse the given value using default number formatter
static java.lang.Boolean getBoolean(java.lang.Object value)
          Return Boolean representation from the given object
static java.lang.Double getDoubleValue(java.lang.Object value)
          Return Double representation from the given object
static javax.swing.text.MaskFormatter getMaskFormatter(java.lang.String mask, java.lang.Character placeHolder)
          Create a MaskFormatter for the given mask and place holder
static javax.swing.event.TableModelEvent getModelEvent(java.lang.Object modelEvent)
          Get TableModelEvent from the given argument
static java.lang.String getValue(javax.swing.text.JTextComponent component)
          Get value of the formatted text field.
static boolean isNull(java.lang.Object value)
          Checks whether the given value is null or empty string
static void removeMaskFormatter(javax.swing.JFormattedTextField fTextField)
          Removes mask formatter from the given formatted text field
static void removeMaskFormatter(javax.swing.JSpinner spinner)
          Removes mask formatter from the given spinner
static void removeSelection(javax.swing.JTable table)
          Removes rows and columns selection from the given table.
static void setEnabled(javax.swing.JComponent component, boolean enabled)
          Enables/disables all child components of the given component
static void setImage(javax.swing.JLabel component, java.lang.String image, java.lang.String tooltip)
          Sets icon and tooltip for the give JLabel component.
static void setMax(double max, javax.swing.JSpinner... spinners)
          Set max value for the given spinners
static void setNormalizedDocument(javax.swing.text.JTextComponent component, int maxLenght)
          Set NormalizedDocument on the given text component
static void setSelectedRow(java.lang.Integer row, javax.swing.JTable table)
          Selects the given row index at the given table.
static void setText(javax.swing.JComponent component, java.lang.String text, java.lang.String tooltip)
          Set the given text on each container components.
static void setValue(double value, javax.swing.JSpinner... spinners)
          Set current value for the given spinners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormHelper

public FormHelper()
Method Detail

getModelEvent

public static javax.swing.event.TableModelEvent getModelEvent(java.lang.Object modelEvent)
Get TableModelEvent from the given argument

Parameters:
modelEvent - instance of table model event
Returns:
instance of TableModelEvent or NULL if given value is not instance of TableModelEvent

isNull

public static boolean isNull(java.lang.Object value)
Checks whether the given value is null or empty string

Parameters:
value - object value
Returns:
true if value is null or empty, false otherwise

getBoolean

public static java.lang.Boolean getBoolean(java.lang.Object value)
Return Boolean representation from the given object

Parameters:
value - object value
Returns:
Boolean.TRUE if string value is not null and equals to true, Boolean.FALSE otherwise

getDoubleValue

public static java.lang.Double getDoubleValue(java.lang.Object value)
Return Double representation from the given object

Parameters:
value - object value
Returns:
Double if string value is not null and can be parsed as double, NULL otherwise

format

public static java.lang.String format(java.lang.Number value)
Parse the given value using default number formatter

Parameters:
value - number value to be parsed
Returns:
parsed given value using default number formatter

setEnabled

public static void setEnabled(javax.swing.JComponent component,
                              boolean enabled)
Enables/disables all child components of the given component

Parameters:
component - parent component

setText

public static void setText(javax.swing.JComponent component,
                           java.lang.String text,
                           java.lang.String tooltip)
Set the given text on each container components. The method is recursive and works for all subcomponents

Parameters:
component - parent component
text - text to be set
tooltip - tooltip to set

setImage

public static void setImage(javax.swing.JLabel component,
                            java.lang.String image,
                            java.lang.String tooltip)
Sets icon and tooltip for the give JLabel component.

Parameters:
component - parent component
text - text to be set
tooltip - tooltip to set

getValue

public static java.lang.String getValue(javax.swing.text.JTextComponent component)
Get value of the formatted text field. If mask formatter is set it returns formatted value. Otherwise it return text value

Parameters:
component - formatted text component

getMaskFormatter

public static javax.swing.text.MaskFormatter getMaskFormatter(java.lang.String mask,
                                                              java.lang.Character placeHolder)
Create a MaskFormatter for the given mask and place holder

Parameters:
mask - mask. Please refer to MaskFormatter for the available choices
placeHolder - place holder character
Returns:
new instance of MaskFormatter or null if Mask Formatter creation failed

removeMaskFormatter

public static void removeMaskFormatter(javax.swing.JFormattedTextField fTextField)
Removes mask formatter from the given formatted text field

Parameters:
fTextField - instance of JFormattedTextField

removeMaskFormatter

public static void removeMaskFormatter(javax.swing.JSpinner spinner)
Removes mask formatter from the given spinner

Parameters:
spinner - instance of JSpinner

setNormalizedDocument

public static void setNormalizedDocument(javax.swing.text.JTextComponent component,
                                         int maxLenght)
Set NormalizedDocument on the given text component

Parameters:
component - text component

setSelectedRow

public static void setSelectedRow(java.lang.Integer row,
                                  javax.swing.JTable table)
Selects the given row index at the given table.

Parameters:
row - row index
table - instance of JTable

removeSelection

public static void removeSelection(javax.swing.JTable table)
Removes rows and columns selection from the given table.

Parameters:
table - instance of JTable

setMax

public static void setMax(double max,
                          javax.swing.JSpinner... spinners)
Set max value for the given spinners

Parameters:
max - max value
spinners - spinner list

setValue

public static void setValue(double value,
                            javax.swing.JSpinner... spinners)
Set current value for the given spinners

Parameters:
value - max value
spinners - spinner list

VLab Common 1.2

Copyright 2004 by VLAB Dominik Stoklosa.