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

PRadioButton

Examples
PContainer container;
PRadioButtonGroup applegroup, orangegroup;
PRadioButton[] radios;
PLabel[] labels;
PLabel apple, orange;

void setup() {
  container = new PContainer();
  container.setBounds(0, 0, width, height);
  
  applegroup = new PRadioButtonGroup();
  orangegroup = new PRadioButtonGroup();
  
  radios = new PRadioButton[4];
  labels = new PLabel[4];
  int x, y = 4;  
  PRadioButton radio;
  PLabel label;
  for (int i = 0; i < 4; i++) {
    if (i < 2) {
      radio = new PRadioButton(false, applegroup);
      label = new PLabel("Apple " + i);      
    } else {
      radio = new PRadioButton(false, orangegroup);
      label = new PLabel("Orange " + (i - 2));
    }
    radio.id = i;
    radio.calculateBounds(4, y, 16, 16);
    
    x = radio.x + radio.width + 2;
    label.calculateBounds(x, y, width - x, height - y);
    
    radios[i] = radio;
    labels[i] = label;
    container.add(radio);
    container.add(label);
    
    y = max(radio.y + radio.height + 2, label.y + label.height + 2);
  }
  apple = new PLabel("No apple");
  apple.calculateBounds(4, y, width - 8, height - y);
  apple.setBounds(4, y, width - 8, apple.height);
  container.add(apple);
  
  y = apple.y + apple.height + 2;
  orange = new PLabel("No orange");
  orange.calculateBounds(4, y, width - 8, height - y);
  orange.setBounds(4, y, width - 8, apple.height);
  container.add(orange);
  
  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 == applegroup) {
    apple.text = labels[applegroup.getSelected().id].text;
  } else if (library == orangegroup) {
    orange.text = labels[orangegroup.getSelected().id].text;
  }
}

Description A radio button component. Used with the PRadioButtonGroup object to present a mutually-exclusive set of selectable options. Does not include a label, use a PLabel object to display a textual label next to it. The size of the component defines the size of the radio button.
Fields
id   This can be any id you wish to set to keep track of your radio buttons

selected   True if this radio button is selected

Methods
keyPressed()   Handles pressing and selecting/de-selecting this radio button when the FIRE button is pressed.

keyReleased()   Releases the pressed state of this button when the FIRE button is released.

Constructors
PRadioButton(selected, group)
Parameters
selected   initial state of this button

group   the group this button is a member of

Related PComponent