Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## josx.platform.rcx
Class Button

    java.lang.Object
      josx.platform.rcx.Button

All Implemented Interfaces:
  ListenerCaller

    public class Button

extends Object
implements ListenerCaller

Abstraction for an RCX button. Example:

``

        Button.RUN.waitForPressAndRelease();
        Sound.playTone (1000, 1);

Field Summary
`static Button[]` | `BUTTONS` Array containing VIEW, PRGM and RUN, in that order.
`static Button` | `PRGM` The Prgm button.
`static Button` | `RUN` The Run button.
`static Button` | `VIEW` The View button.

Method Summary
`void` | `addButtonListener(ButtonListener aListener)` Adds a listener of button events.
`void` | `callListeners()`
`int` | `getId()` Return the ID of the button.
`boolean` | `isPressed()`
`static int` | `readButtons()` Low-level API that reads status of buttons.
`void` | `waitForPressAndRelease()` Wait until the button is released.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait`

Field Detail

### RUN

    public static final Button RUN

  The Run button.

### VIEW

    public static final Button VIEW

  The View button.

### PRGM

    public static final Button PRGM

  The Prgm button.

### BUTTONS

    public static final Button[] BUTTONS

  Array containing VIEW, PRGM and RUN, in that order.

Method Detail

### getId

    public final int getId()

  Return the ID of the button. One of 1, 2 or 4.

### isPressed

    public final boolean isPressed()

  Returns:
    `true` if button is pressed, `false` otherwise.

### waitForPressAndRelease

    public final void waitForPressAndRelease()
                                      throws InterruptedException

  Wait until the button is released.

  Throws:
    `InterruptedException`

### addButtonListener

    public void addButtonListener(ButtonListener aListener)

  Adds a listener of button events. Each button can serve at most 4 listeners.

### readButtons

    public static int readButtons()

  Low-level API that reads status of buttons.

  Returns:
    An integer with possibly some bits set: 0x02 (view button pressed) 0x04 (prgm button pressed), 0x01 (run button pressed). If all buttons are released, this method returns 0.

### callListeners

    public void callListeners()

  Specified by:
    `callListeners` in interface `ListenerCaller`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD