Class WidgetFactory

java.lang.Object
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
  • Field Details

    • 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 Details

    • WidgetFactory

      public WidgetFactory()
  • Method Details

    • 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)