gov.nih.mipav.view.components
Class WidgetFactory

java.lang.Object
  extended by gov.nih.mipav.view.components.WidgetFactory

public class WidgetFactory
extends Object

This class is a collection of GUI widget generation methods. Widgets are created in a MIPAV-consistent manner and style.

Author:
mccreedy

Nested Class Summary
static class WidgetFactory.ScrollTextArea
          ScrollPane with an accessible JTextArea
 
Field Summary
static Font courier10
          A 10 point, plain, courier font.
static Font courier12
          A 12 point, plain, courier font.
static Font courier12B
          A 12 point, bold, courier font.
static Font font10
          A 10 point, plain, serif font.
static Font font12
          A 12 point, plain, serif font.
static Font font12B
          A 12 point, bold, serif font.
static Font font12I
          A 12 point, italic, serif font.
static Font font13B
          A 13 point, bold, serif font.
static Font font14
          A 14 point, plain, serif font.
static Font font14B
          A 14 point, bold, serif font.
static Font font16B
          A 16 point, bold, serif font.
static Font font18B
          A 18 point, bold, serif font.
 
Constructor Summary
WidgetFactory()
           
 
Method Summary
static JCheckBox buildCheckBox(String label, boolean isSelected)
          Builds a new check box component.
static JCheckBox buildCheckBox(String label, boolean isSelected, ItemListener listener)
          Builds a new check box component.
static JButton buildIconButton(Icon icon, String toolTip, String action, ActionListener listener)
          Helper method to build a icon button.
static JLabel buildLabel(String text)
          Builds a label with the proper font and font color.
static JPasswordField buildPasswordField()
          Helper method to create a password field with the proper font and font color.
static Border buildPressedButtonBorder()
          Builds a new border of the type used when a toggle button is depressed.
static JRadioButton buildRadioButton(String label, boolean isSelected, ButtonGroup group)
          Builds a new radio button component.
static JScrollPane buildScrollPane(JComponent component)
          Create a new scroll pane, containing a component.
static JScrollPane buildScrollPane(JComponent component, int preferredWidth, int preferredHeight)
          Create a new scroll pane, containing a component.
static WidgetFactory.ScrollTextArea buildScrollTextArea(Color bg)
           
static JTextArea buildTextArea(String text, boolean isEditable)
          Builds a new text area.
static JButton buildTextButton(String text, String toolTip, String action, ActionListener listener)
          Helper method to build a text button.
static JTextField buildTextField(String text)
          Helper method to create a text field with the proper font and font color.
static Border buildTitledBorder(String title)
          Builds a titled border with the given title, an etched border, and the proper font and color.
static Border buildToolbarBorder()
          Builds a new border of the type used by toolbars.
static Dimension getDefaultButtonSize()
          Returns the default size used for most text buttons.
static ImageIcon getIcon(String name)
          Finds the icon of the specified name.
static Image getIconImage(String name)
          Finds the image of the specified name.
static JToolBar initToolbar()
          Create a blank toolbar and set it up.
static JButton makeToolbarSeparator()
          Makes a separator for the use in the toolbars - a button with the proper icon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

font10

public static final Font font10
A 10 point, plain, serif font.


font12

public static final Font font12
A 12 point, plain, serif font.


font12B

public static final Font font12B
A 12 point, bold, serif font.


font12I

public static final Font font12I
A 12 point, italic, serif font.


font13B

public static final Font font13B
A 13 point, bold, serif font.


font14

public static final Font font14
A 14 point, plain, serif font.


font14B

public static final Font font14B
A 14 point, bold, serif font.


font16B

public static final Font font16B
A 16 point, bold, serif font.


font18B

public static final Font font18B
A 18 point, bold, serif font.


courier10

public static final Font courier10
A 10 point, plain, courier font.


courier12

public static final Font courier12
A 12 point, plain, courier font.


courier12B

public static final Font courier12B
A 12 point, bold, courier font.

Constructor Detail

WidgetFactory

public WidgetFactory()
Method Detail

buildCheckBox

public static final JCheckBox buildCheckBox(String label,
                                            boolean isSelected)
Builds a new check box component.

Parameters:
label - the label to place in front of the check box
isSelected - whether the check box should initially be selected
Returns:
the new check box

buildCheckBox

public static final JCheckBox buildCheckBox(String label,
                                            boolean isSelected,
                                            ItemListener listener)
Builds a new check box component.

Parameters:
label - the label to place in front of the check box
isSelected - whether the check box should initially be selected
listener - the object to notify of ItemEvents generated by this check box (on selection/deselction)
Returns:
the new check box

buildLabel

public static final JLabel buildLabel(String text)
Builds a label with the proper font and font color.

Parameters:
text - text of the label
Returns:
the new label

buildPasswordField

public static final JPasswordField buildPasswordField()
Helper method to create a password field with the proper font and font color.

Returns:
New password field.

buildPressedButtonBorder

public static final Border buildPressedButtonBorder()
Builds a new border of the type used when a toggle button is depressed.

Returns:
a new border

buildRadioButton

public static final JRadioButton buildRadioButton(String label,
                                                  boolean isSelected,
                                                  ButtonGroup group)
Builds a new radio button component.

Parameters:
label - the label to place in front of the radio button
isSelected - whether the check box should initially be selected
group - the button group to add the new radio button to
Returns:
the new radio button

buildScrollPane

public static final JScrollPane buildScrollPane(JComponent component)
Create a new scroll pane, containing a component.

Parameters:
component - the component to put inside the scroll pane
Returns:
the new scroll pane

buildScrollPane

public static final JScrollPane buildScrollPane(JComponent component,
                                                int preferredWidth,
                                                int preferredHeight)
Create a new scroll pane, containing a component.

Parameters:
component - the component to put inside the scroll pane
preferredWidth - the width of the scroll pane
preferredHeight - the height of the scroll pane
Returns:
the new scroll pane

buildTextArea

public static final JTextArea buildTextArea(String text,
                                            boolean isEditable)
Builds a new text area.

Parameters:
text - the text to put inside the text area
isEditable - whether the text area should be editable by the user
Returns:
the new text area

buildTextButton

public static final JButton buildTextButton(String text,
                                            String toolTip,
                                            String action,
                                            ActionListener listener)
Helper method to build a text button.

Parameters:
text - Text for button.
toolTip - Tool tip to be associated with button.
action - Action command for button.
listener - the listener for this button's actions
Returns:
a new text button

buildIconButton

public static final JButton buildIconButton(Icon icon,
                                            String toolTip,
                                            String action,
                                            ActionListener listener)
Helper method to build a icon button.

Parameters:
icon - icon for button.
toolTip - Tool tip to be associated with button.
action - Action command for button.
listener - the listener for this button's actions
Returns:
a new text button

buildTextField

public static final JTextField buildTextField(String text)
Helper method to create a text field with the proper font and font color.

Parameters:
text - Text int the field.
Returns:
New text field.

buildTitledBorder

public static final Border buildTitledBorder(String title)
Builds a titled border with the given title, an etched border, and the proper font and color.

Parameters:
title - the title of the border
Returns:
the titled border.

buildToolbarBorder

public static final Border buildToolbarBorder()
Builds a new border of the type used by toolbars.

Returns:
a new border

getDefaultButtonSize

public static final Dimension getDefaultButtonSize()
Returns the default size used for most text buttons.

Returns:
the default text button size

getIcon

public static final ImageIcon getIcon(String name)
Finds the icon of the specified name. Uses the PlaceHolder class, which is in the same directory as the icons, to locate the icons.

Parameters:
name - name of the icon
Returns:
the icon

getIconImage

public static final Image getIconImage(String name)
                                throws FileNotFoundException
Finds the image of the specified name. Uses the PlaceHolder class, which is in the same directory as the icons images, to locate the images.

Parameters:
name - name of the image
Returns:
the image
Throws:
FileNotFoundException - if we can't find the icon file

initToolbar

public static final JToolBar initToolbar()
Create a blank toolbar and set it up.

Returns:
a new toolbar

makeToolbarSeparator

public static final JButton makeToolbarSeparator()
Makes a separator for the use in the toolbars - a button with the proper icon.

Returns:
The new separator.

buildScrollTextArea

public static final WidgetFactory.ScrollTextArea buildScrollTextArea(Color bg)