Package sim.util.gui

Class LabelledList

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
SeriesAttributes

public class LabelledList extends JPanel
LabelledList is a JPanel which makes it easy to set up two columns of Components, with the right column taking up the extra space if there is any. Additionally, you can add up to three interpersed columns for checkboxes or icons or bullets or the like.

The columns are:

  1. Far Left. Left-justified.
  2. Left. Right-justified. Typically used for a string label describing the Right component.
  3. Center. Center-justified.
  4. Right. Left-justified, fills up all extra space. The primary component.
  5. Far Right. Right-justified.

Most commonly, you would have the right column be widgets and the left column be the labels describing those widgets. Two special methods are provided: add(Component,Component) lets you explicitly add a new row consisting of a component in the left column and another in the right column. addLabelled(String,Component) lets you add a new row with a component in the right column and a JLabel showing the given string in the left column.

The general method is add(Component,Component,Component,Component,Component) to add up to all five columns.

LabelledList uses BorderLayout as its layout manager. Please do not change it. However, your are welcome to add subcomponents anywhere but BorderLayout.NORTH, which is where the columns hang down from.

There is no way to remove components (this is a very simple class!). What did you want, a JTable? Sheesh!

See Also:
  • Constructor Details

    • LabelledList

      public LabelledList()
    • LabelledList

      public LabelledList(String borderLabel)
      Creates a Labelled List with a provided border label. If label is null, just does new LabelledList()
  • Method Details

    • addLabelled

      public void addLabelled(String left, Component right)
      Creates a new row, with the given components in the right column, and a JLabel of the given string in the left column. The component and the label may be null.
    • add

      public void add(Component left, Component right)
      Creates a new row, with the given components in the left and right columns of the row respectively. Either component may be null.
    • add

      public void add(Component farLeft, Component left, Component center, Component right, Component farRight)
      Creates a new row, with the given components in the farLeft, left, center, right, and farRight columns respectively. Any component may be null.
    • add

      public Component add(Component comp)
      Inserts a component spanning all five columns.
      Overrides:
      add in class Container
    • addComponent

      public void addComponent(Component comp)
      Deprecated.
      Inserts a component spanning all five columns. Synonym for add(comp)