Notice: This is a static archive of the Mobile Processing website, as the project is no longer significantly active. All forms and the Discourse boards are no longer functional, and the mobile website at http://wapmp.at/ is no longer available. Please visit the Mobile Processing Google Group for any remaining discussions and the Processing website for the latest news about Processing.
Index
Name

PList

Examples
PContainer container;
PLabel label;
PList list;
PScrollBar scrollbar;

void setup() {
  container = new PContainer();
  container.setBounds(0, 0, width, height);
  
  label = new PLabel("Selected: ");
  //// let the label calculate its ideal width/height
  label.calculateBounds(0, 0, width, height);
  //// set the label to fill the full width of the screen
  label.setBounds(0, 0, width, label.height);
  container.add(label);
  
  int y = label.y + label.height;
      
  //// put a scrollbar on the right side of the screen
  //// we do not need to explicitly add it to the container
  //// since it will be linked to the list
  scrollbar = new PScrollBar();
  scrollbar.setBounds(width - 4, y, 4, height -y);
  
  //// create a new list
  list = new PList();
  list.scrollbar = scrollbar;
  list.setBounds(0, y, width - 4, height - y);
  for (int i = 0; i < 25; i++) {
    list.add(i + ". The quick brown fox jumped over the lazy dogs.");
  }
  container.add(list);
  
  container.initialize();
  container.acceptFocus();
}

void draw() {
  container.draw();
}

void keyPressed() {
  container.keyPressed();
}

void keyReleased() {
  container.keyReleased();
}

void libraryEvent(Object library, int event, Object data) {
  if (library == list) {
    //// update selection label
    label.text = "Selected: " + list.selected;
  }
}

Description A scrollable list. Each item in the list is represented by a single line label. If the label is bigger than the width of the component, it will scroll horizontally when selected. Note that the horizontal scrolling will only animate when the list has the input focus.
Fields
font   The font used to display the item labels

scrollbar   The scrollbar used to represent the size of the list contents

selected   Index of the currently selected item in the list

Methods
add()   Adds items to this list.

get()   Returns the item in the list at the specified index

initialize()   Initializes the list, sets up its associated scrollbar

keyPressed()   Handles up/down navigation of the list and pressed selection of items in the list

keyReleased()   Releases the pressed state of items in the list, fires a library event to notify the sketch of the selection.

Constructors
PList()
Related PComponent