Class LabelledComponentStack

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class LabelledComponentStack extends JPanel
A component which contains a list of (name, component) pairs. The components will typically be text fields or other things into which the user can enter input; the names labels for these. Alignment is taken care of. This class is a convenience for a number of widgets which need to do the same sort of thing.
Author:
Mark Taylor (Starlink)
See Also:
  • Constructor Details

    • LabelledComponentStack

      public LabelledComponentStack()
      Constructs a new stack of input fields.
  • Method Details

    • addLine

      public void addLine(String name, String pad, Component comp)
      Adds a (name,component) pair with an optional padding string and default xfill.
      Parameters:
      name - the component label, which gets displayed as a JLabel
      pad - an extra string which is aligned between the name and component
      comp - the component
    • addLine

      public void addLine(String name, String pad, Component comp, boolean xfill)
      Adds a (name,component) pair with an optional padding string and explicit xfill.
      Parameters:
      name - the component label, which gets displayed as a JLabel
      pad - an extra string which is aligned between the name and component
      comp - the component
      xfill - true iff the component should be stretched to the full available width
    • addLine

      public void addLine(String name, Component comp)
      Adds a (name,component) pair.
      Parameters:
      name - the component label, which gets displayed as a JLabel
      comp - the component
    • addLine

      public void addLine(String name, String value)
      Adds a (name,value) pair. The value is a string which will be presented as a JLabel or something.
    • getInputFont

      public Font getInputFont()
      Returns the font used for dialog boxes.
      Returns:
      font
    • getLabels

      public JLabel[] getLabels()
      Returns an array of labels which have been added. Each corresponds to the name argument of an addLine call.
      Returns:
      an array of JLabels, one for each line
    • getFields

      public Component[] getFields()
      Returns an array of the components which have been added. Each corresponds to the comp argument of an addLine call.
      Returns:
      an array of field components, one for each line