Class FieldPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class FieldPanel extends JPanel
Utility class for displaying fields in a dialog. Using this class should give a consistent appearance across dialogs. Labels and will be left justified. Fields will also be left justified unless they are resizeable, in which case they will consume excess horizontal space. Best practice: do not append colons to field labels. If we decide to use colons after field labels, we can apply the change to all fields by editing this class.

Users should not manually add or remove components via standard JPanel calls. Instead, they should use Map methods. We can't make these methods throw UnsupportedOperationExceptions because superclasses end up calling the virtual methods.

FieldPanel Example TODO: Add methods to set fill and weighty

See Also:
  • Constructor Details

    • FieldPanel

      public FieldPanel()
    • FieldPanel

      public FieldPanel(String pLabelText, Component pComponent)
    • FieldPanel

      public FieldPanel(Map<String,? extends Component> pStrToFieldMap)
      Populate panel with labels and fields.
      Parameters:
      pStrToFieldMap - map from label string to field.
  • Method Details

    • getFieldToLabelMap

      public Map<Component,JLabel> getFieldToLabelMap()
      Stores components and corresponding labels. Backed by panel. Edits to panel contents should be made through this map. We use a field to label map (rather than the reverse) so that multiple fields can use null as a label.
    • getLayout

      public GridBagLayout getLayout()
      Overrides:
      getLayout in class Container
    • main

      public static void main(String[] pArgs)