Example #1
0
  protected ListBox(
      ControlP5 theControlP5,
      ControllerGroup<?> theGroup,
      String theName,
      int theX,
      int theY,
      int theW,
      int theH) {
    super(theControlP5, theGroup, theName, theX, theY, theW, 9);

    items = new ArrayList<ListBoxItem>();

    buttons = new ArrayList<Button>();

    _myWidth = theW;

    _myName = theName;

    // workaround fix see code.goode.com/p/controlp5 issue 7
    _myBackgroundHeight = theH < 10 ? 10 : theH;

    _myScrollbar =
        new Slider(
            cp5,
            _myParent,
            theName + "Scroller",
            0,
            1,
            1,
            _myWidth - _myScrollbarWidth,
            0,
            _myScrollbarWidth,
            _myBackgroundHeight);
    _myScrollbar.setBroadcast(false);
    _myScrollbar.setSliderMode(Slider.FLEXIBLE);
    _myScrollbar.setMoveable(false);
    _myScrollbar.setLabelVisible(false);
    _myScrollbar.setParent(this);
    _myScrollbar.addListener(this);
    _myScrollbar.setVisible(false);
    _myScrollbar.hide();
    _myScrollbar.updateDisplayMode(DEFAULT);
    add(_myScrollbar);
    setHeight(_myBackgroundHeight);
  }