# Class VirtualButton

java.lang.Object
com.codename1.gaming.VirtualButton

public class VirtualButton extends Object

An on-screen touch button. Add one with `TouchControls#addButton(int, float, float, float)`; while a finger is on it the framework holds down the key code it is mapped to, so `GameInput#isKeyDown(int)` and `GameInput#wasKeyPressed(int)` report it exactly as a hardware key. Map it to a game action with `com.codename1.ui.Display#getKeyCode(int)` (e.g. `Display.getInstance().getKeyCode(Display.GAME_FIRE)`) or to any key code of your own.

The position and radius are in the `GameView`'s pixel coordinates.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `float`
  `getCenterX()`
  `float`
  `getCenterY()`
  `int`
  `getColor()`
  `int`
  `getKeyCode()`
  `String`
  `getLabel()`
  `float`
  `getRadius()`
  `boolean`
  `isPressed()`
  `VirtualButton`
  `setColor(int argb)`
  The ARGB color the button is tinted (default a translucent white).
  `VirtualButton`
  `setLabel(String label)`
  Optional short label drawn on the button (for example "A" or "Fire").

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### setLabel

    public VirtualButton setLabel(String label)
    Optional short label drawn on the button (for example "A" or "Fire").

  - ### setColor

    public VirtualButton setColor(int argb)
    The ARGB color the button is tinted (default a translucent white).

  - ### isPressed

    public boolean isPressed()

  - ### getKeyCode

    public int getKeyCode()

  - ### getCenterX

    public float getCenterX()

  - ### getCenterY

    public float getCenterY()

  - ### getRadius

    public float getRadius()

  - ### getLabel

    public String getLabel()

  - ### getColor

    public int getColor()