uk.ac.cisban.rod.gui
Class UtilityMethods

java.lang.Object
  extended by uk.ac.cisban.rod.gui.UtilityMethods

public class UtilityMethods
extends java.lang.Object

Contains a series of static methods intended to simplify coding interfaces in Java Swing.

Author:
morgan

Constructor Summary
UtilityMethods()
           
 
Method Summary
static void addSeparator(javax.swing.JPanel panel, int separatorType, int size)
          Adds a separator of the given separatorType (one of SwingConstants.VERTICAL or SwingConstants.HORIZONTAL) with buffering around it.
static javax.swing.table.DefaultTableModel clearTableModel(javax.swing.table.DefaultTableModel model)
           
static javax.swing.JComponent constrainJComponentSize(javax.swing.JComponent txtfld)
           
static javax.swing.JLabel createLabel(java.lang.String text)
          Creates a label
static javax.swing.JLabel createLabel(java.lang.String text, int width)
          Creates a label and sets it to a specific size so that they line up nicely in the GUI
static javax.swing.JTextField createTextField(java.lang.String text, int width)
           
static javax.swing.JPanel getNewPanel(int boxOrientation)
           
static javax.swing.text.JTextComponent initializeTextComponent(javax.swing.text.JTextComponent comp)
           
static void setEnabled(java.awt.Component j, boolean enabled)
           
static int showFileChooser(javax.swing.JFileChooser fileChooser, int chooserType, java.awt.Component c)
          Opens a save or open JFileChooser and saves the position where it was opened.
static int showFolderChooser(javax.swing.JFileChooser fileChooser, java.awt.Component c)
           
static int showOptionDialog(java.lang.String title, java.lang.Object message)
           
static int showResizeableDialog(java.lang.String title, javax.swing.JComponent message)
           
static void turnColor(java.awt.Component component)
           
static void turnColors(java.awt.Component[] components, java.awt.Color color)
           
static void validateDateComponent(java.text.SimpleDateFormat format, javax.swing.text.JTextComponent component)
           
static void validateJTextComponent(javax.swing.text.JTextComponent component)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UtilityMethods

public UtilityMethods()
Method Detail

createLabel

public static javax.swing.JLabel createLabel(java.lang.String text,
                                             int width)
Creates a label and sets it to a specific size so that they line up nicely in the GUI

Parameters:
text - the text to include
width - the width of the label
Returns:
a JLabel

addSeparator

public static void addSeparator(javax.swing.JPanel panel,
                                int separatorType,
                                int size)
Adds a separator of the given separatorType (one of SwingConstants.VERTICAL or SwingConstants.HORIZONTAL) with buffering around it.


createLabel

public static javax.swing.JLabel createLabel(java.lang.String text)
Creates a label

Parameters:
text - the text to include
width - the width of the label
Returns:
a JLabel

createTextField

public static javax.swing.JTextField createTextField(java.lang.String text,
                                                     int width)

initializeTextComponent

public static javax.swing.text.JTextComponent initializeTextComponent(javax.swing.text.JTextComponent comp)

constrainJComponentSize

public static javax.swing.JComponent constrainJComponentSize(javax.swing.JComponent txtfld)

showOptionDialog

public static int showOptionDialog(java.lang.String title,
                                   java.lang.Object message)

showResizeableDialog

public static int showResizeableDialog(java.lang.String title,
                                       javax.swing.JComponent message)

clearTableModel

public static javax.swing.table.DefaultTableModel clearTableModel(javax.swing.table.DefaultTableModel model)

showFileChooser

public static int showFileChooser(javax.swing.JFileChooser fileChooser,
                                  int chooserType,
                                  java.awt.Component c)
Opens a save or open JFileChooser and saves the position where it was opened. Where chooserType is one of JFileChooser.OPEN_DIALOG or JFileChooser.SAVE_DIALOG.

Parameters:
fileChooser - a JFileChooser
chooserType - the type of chooser, eg. JFileChooser.OPEN_DIALOG or JFileChooser.SAVE_DIALOG
c - the parent component
Returns:
the int from the JFileChooser

showFolderChooser

public static int showFolderChooser(javax.swing.JFileChooser fileChooser,
                                    java.awt.Component c)

setEnabled

public static void setEnabled(java.awt.Component j,
                              boolean enabled)

validateJTextComponent

public static void validateJTextComponent(javax.swing.text.JTextComponent component)
                                   throws IncorrectInputException
Throws:
IncorrectInputException

validateDateComponent

public static void validateDateComponent(java.text.SimpleDateFormat format,
                                         javax.swing.text.JTextComponent component)
                                  throws IncorrectInputException
Throws:
IncorrectInputException

turnColors

public static void turnColors(java.awt.Component[] components,
                              java.awt.Color color)

getNewPanel

public static javax.swing.JPanel getNewPanel(int boxOrientation)

turnColor

public static void turnColor(java.awt.Component component)


Copyright © 2010. All Rights Reserved.