info.joseluismartin.gui.form
Class FormUtils

java.lang.Object
  extended by info.joseluismartin.gui.form.FormUtils

public abstract class FormUtils
extends Object

Static utility library for use in Swing Forms

Author:
Jose Luis Martin - (jlm@joseluismartin.info)

Field Summary
static Icon CANCEL_ICON
           
static Icon OK_ICON
           
 
Constructor Summary
FormUtils()
           
 
Method Summary
static Border createEmptyBorder(int size)
          Creates empty border
static Border createTitledBorder(String name)
          Create Titled Border
static List<Object> getComboModelList(ComboBoxModel model)
          Return a List of Objects from a ComboBoxModel
static Icon getIcon(Icon icon, String url)
          Load icon if icon = null, else return icon.
static Icon getIcon(String url)
          Load Icon from url
static void link(JComboBox primary, JComboBox dependent, String propertyName)
           
static void link(JComboBox primary, JComboBox dependent, String propertyName, boolean addNull)
          Add a link on primary and dependent JComboBoxes by property name.
static JButton newCancelButton()
          Get Default OK Button from LookAndFeel (like JOptionPane)
static JComboBox newCombo(int chars)
           
static JDialog newDialog(Component component)
          Creates a new JDialog with default accept/cancel buttons
static JDialog newDialog(Window owner, Component component)
          Creates a new JDialog with default accept/cancel buttons
static JLabel newLabelForBox(String message)
           
static JButton newOKButton()
          Get Default OK Button from LookAndFeel (like JOptionPane)
static void setBold(JLabel label)
          Make font of JLabel bold
static void showError(Component parent, String message)
          Show error message
static void showError(String message)
          Show error message
static JMenu toMenu(List<Action> actions)
          Make a JMenu from an Action List
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CANCEL_ICON

public static final Icon CANCEL_ICON

OK_ICON

public static final Icon OK_ICON
Constructor Detail

FormUtils

public FormUtils()
Method Detail

link

public static void link(JComboBox primary,
                        JComboBox dependent,
                        String propertyName)

link

public static void link(JComboBox primary,
                        JComboBox dependent,
                        String propertyName,
                        boolean addNull)
Add a link on primary and dependent JComboBoxes by property name. When selection changes on primary use propertyName to get a Collection and fill dependent JComboBox with it

Parameters:
primary - JComboBox when selection changes
dependent - JComboBox that are filled with collection
propertyName - the property name for get the collection from primary selected item
addNull - if true, add a null as first combobox item

getComboModelList

public static List<Object> getComboModelList(ComboBoxModel model)
Return a List of Objects from a ComboBoxModel

Parameters:
model - ComboBoxModel
Returns:
a list of Objects with ComboBoxModel items

newCombo

public static JComboBox newCombo(int chars)

setBold

public static void setBold(JLabel label)
Make font of JLabel bold

Parameters:
label - JLabel to make bold

createTitledBorder

public static Border createTitledBorder(String name)
Create Titled Border

Parameters:
name - the title
Returns:
Border

newOKButton

public static JButton newOKButton()
Get Default OK Button from LookAndFeel (like JOptionPane)


newCancelButton

public static JButton newCancelButton()
Get Default OK Button from LookAndFeel (like JOptionPane)


getIcon

public static Icon getIcon(String url)
Load Icon from url

Parameters:
url -
Returns:
Icon, null on faliure

getIcon

public static Icon getIcon(Icon icon,
                           String url)
Load icon if icon = null, else return icon.

Parameters:
icon - icon to load
url - String with url
Returns:
icon

toMenu

public static JMenu toMenu(List<Action> actions)
Make a JMenu from an Action List

Parameters:
actions - the Action List
Returns:
JMenu

newLabelForBox

public static JLabel newLabelForBox(String message)
Parameters:
message -
Returns:
JLabel

showError

public static void showError(String message)
Show error message

Parameters:
message - message to show

showError

public static void showError(Component parent,
                             String message)
Show error message

Parameters:
parent - component parent
message - message to show

newDialog

public static JDialog newDialog(Component component)
Creates a new JDialog with default accept/cancel buttons

Parameters:
component - to show in
Returns:
new created dialog

newDialog

public static JDialog newDialog(Window owner,
                                Component component)
Creates a new JDialog with default accept/cancel buttons

Parameters:
owner - owner window
component - component to show in
Returns:
new crated dialog

createEmptyBorder

public static Border createEmptyBorder(int size)
Creates empty border

Parameters:
size - border size
Returns:
empty border


Copyright © 2013 JDAL. All Rights Reserved.