ui/src/main/java/ucar/nc2/ui/widget/BAMutil.java
public static AbstractButton addActionToContainerPos( Container c, Action act, int pos) {
    AbstractButton butt = _makeButtconFromAction( act);
    if (pos < 0)
      c.add( butt);
    else
      c.add(butt, pos);

    if (debug) System.out.println(" addActionToContainerPos "+ act+ " "+ butt+ " "+ pos);

    Boolean tog = (Boolean) act.getValue( BAMutil.TOGGLE);
    boolean is_toggle = (tog == null ) ? false : tog.booleanValue();

      // set state for toggle buttons
    if (is_toggle) {
      if (debugToggle)
        System.out.println("addActionToContainerPos: "+ act.getValue( Action.SHORT_DESCRIPTION)+" "+act.getValue( BAMutil.STATE));
      Boolean state = (Boolean) act.getValue( BAMutil.STATE);
      if (state == null) state = Boolean.FALSE;
      act.putValue(BAMutil.STATE, state);
      butt.setSelected(state.booleanValue());
    }

      // add event listsners
    Action myAct = is_toggle ? new ToggleAction( act) : act;
    butt.addActionListener( myAct);
    act.addPropertyChangeListener(new myActionChangedListener(butt));

    return butt;
  }
public static AbstractButton addActionToContainerPos( Container c, Action act, int pos) {
    AbstractButton butt = _makeButtconFromAction( act);
    if (pos < 0)
      c.add( butt);
    else
      c.add(butt, pos);

    if (debug) System.out.println(" addActionToContainerPos "+ act+ " "+ butt+ " "+ pos);

    Boolean tog = (Boolean) act.getValue( BAMutil.TOGGLE);
    boolean is_toggle = (tog == null ) ? false : tog.booleanValue();

      // set state for toggle buttons
    if (is_toggle) {
      if (debugToggle)
        System.out.println("addActionToContainerPos: "+ act.getValue( Action.SHORT_DESCRIPTION)+" "+act.getValue( BAMutil.STATE));
      Boolean state = (Boolean) act.getValue( BAMutil.STATE);
      if (state == null) state = Boolean.FALSE;
      act.putValue(BAMutil.STATE, state);
      butt.setSelected(state.booleanValue());
    }

      // add event listsners
    Action myAct = is_toggle ? new ToggleAction( act) : act;
    butt.addActionListener( myAct);
    act.addPropertyChangeListener(new myActionChangedListener(butt));

    return butt;
  }
creates an AbstractButton using the given Action and adds it to the given Container at the position..
Uses Properties that have been set on the Action (see setActionProperties()). All
are optional except for Action.SMALL_ICON:  <pre>
Action.SMALL_ICON          Icon       the Icon to Use (required)
BAMutil.SELECTED_ICON      Icon       the Icon when selected (optional)
Action.SHORT_DESCRIPTION   String     tooltip
BAMutil.TOGGLE             Boolean    true if its a toggle
</pre><br>
The Action is triggered when the Button is selected. Enabling and disabling the Action
does the same for the Button. For toggles, state is maintained in the Action,
and the Button state changes when the Action state changes. <br><br>
The point of all this is that once you set it up, you work exclusively with the action object,
and all changes are automatically reflected in the UI.

@param c  add to this Container
@param act the Action to make it out of
@param pos add to the container at this position (if pos < 0, add at the end)
@return the AbstractButton created  (JButton or JToggleButton)