Package gov.nih.mipav.view.components
Class WidgetFactory
java.lang.Object
gov.nih.mipav.view.components.WidgetFactory
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
Nested ClassesModifier and TypeClassDescriptionstatic final classScrollPane with an accessible JTextArea -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final FontA 10 point, plain, courier font.static final FontA 12 point, plain, courier font.static final FontA 12 point, bold, courier font.static final FontA 10 point, plain, serif font.static final FontA 12 point, plain, serif font.static final FontA 12 point, bold, serif font.static final FontA 12 point, italic, serif font.static final FontA 13 point, bold, serif font.static final FontA 14 point, plain, serif font.static final FontA 14 point, bold, serif font.static final FontA 16 point, bold, serif font.static final FontA 18 point, bold, serif font. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final JCheckBoxbuildCheckBox(String label, boolean isSelected) Builds a new check box component.static final JCheckBoxbuildCheckBox(String label, boolean isSelected, ItemListener listener) Builds a new check box component.static final JButtonbuildIconButton(Icon icon, String toolTip, String action, ActionListener listener) Helper method to build a icon button.static final JLabelbuildLabel(String text) Builds a label with the proper font and font color.static final JPasswordFieldHelper method to create a password field with the proper font and font color.static final BorderBuilds a new border of the type used when a toggle button is depressed.static final JRadioButtonbuildRadioButton(String label, boolean isSelected, ButtonGroup group) Builds a new radio button component.static final JScrollPanebuildScrollPane(JComponent component) Create a new scroll pane, containing a component.static final JScrollPanebuildScrollPane(JComponent component, int preferredWidth, int preferredHeight) Create a new scroll pane, containing a component.static final WidgetFactory.ScrollTextAreastatic final JTextAreabuildTextArea(String text, boolean isEditable) Builds a new text area.static final JButtonbuildTextButton(String text, String toolTip, String action, ActionListener listener) Helper method to build a text button.static final JTextFieldbuildTextField(String text) Helper method to create a text field with the proper font and font color.static final BorderbuildTitledBorder(String title) Builds a titled border with the given title, an etched border, and the proper font and color.static final BorderBuilds a new border of the type used by toolbars.static final DimensionReturns the default size used for most text buttons.static final ImageIconFinds the icon of the specified name.static final ImagegetIconImage(String name) Finds the image of the specified name.static final JToolBarCreate a blank toolbar and set it up.static final JButtonMakes a separator for the use in the toolbars - a button with the proper icon.
-
Field Details
-
font10
A 10 point, plain, serif font. -
font12
A 12 point, plain, serif font. -
font12B
A 12 point, bold, serif font. -
font12I
A 12 point, italic, serif font. -
font13B
A 13 point, bold, serif font. -
font14
A 14 point, plain, serif font. -
font14B
A 14 point, bold, serif font. -
font16B
A 16 point, bold, serif font. -
font18B
A 18 point, bold, serif font. -
courier10
A 10 point, plain, courier font. -
courier12
A 12 point, plain, courier font. -
courier12B
A 12 point, bold, courier font.
-
-
Constructor Details
-
WidgetFactory
public WidgetFactory()
-
-
Method Details
-
buildCheckBox
Builds a new check box component.- Parameters:
label- the label to place in front of the check boxisSelected- 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 boxisSelected- whether the check box should initially be selectedlistener- the object to notify of ItemEvents generated by this check box (on selection/deselction)- Returns:
- the new check box
-
buildLabel
Builds a label with the proper font and font color.- Parameters:
text- text of the label- Returns:
- the new label
-
buildPasswordField
Helper method to create a password field with the proper font and font color.- Returns:
- New password field.
-
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 buttonisSelected- whether the check box should initially be selectedgroup- the button group to add the new radio button to- Returns:
- the new radio button
-
buildScrollPane
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 panepreferredWidth- the width of the scroll panepreferredHeight- the height of the scroll pane- Returns:
- the new scroll pane
-
buildTextArea
Builds a new text area.- Parameters:
text- the text to put inside the text areaisEditable- 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
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
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
Builds a new border of the type used by toolbars.- Returns:
- a new border
-
getDefaultButtonSize
Returns the default size used for most text buttons.- Returns:
- the default text button size
-
getIcon
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
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
Create a blank toolbar and set it up.- Returns:
- a new toolbar
-
makeToolbarSeparator
Makes a separator for the use in the toolbars - a button with the proper icon.- Returns:
- The new separator.
-
buildScrollTextArea
-