Interfascia

Class Listing

IFTextField
IFRadioController
IFRadioButton
IFProgressBar
IFLookAndFeel
IFLabel
IFCheckBox
IFButton
GUIEvent
actionPerformed
GUIController

Examples

Text Field
Temperature Converter
Radio Buttons
Custom Widget Color
Button

IFCheckBox

The IFCheckBox object creates a new check box GUI component.

Syntax

IFCheckBox c = new IFCheckBox("Enable", 30, 30);
c.addActionListener(this);

Method Summary

IFCheckBox(String label, int x, int y);

  • label, the text displayed next to the check box.
  • x, the X position of the check box.
  • y, the Y position of the check box's upper .

setLabel(String newLabel)

  • Sets the name of the check box. The check box name is used when submitting the interface's current state to a web server.
  • newLabel, the new name for the check box.

getLabel()

  • Returns the check box's name as a String.

setWidth(int width)

  • Sets the width of the check box.
  • width, the new width for the check box.

getWidth()

  • Returns the width in pixels of the check box in integer form.

setHeight(int height)

  • Sets the height of the check box.
  • height, the new height for the check box.

getHeight()

  • Returns the height in pixels of the check box in integer form.

setSize(int width, int height)

  • A convenience method to set both dimensions of the check box.
  • width, the new width for the check box.
  • height, the new height for the check box.

setX(int x)

  • Sets the X position of the check box relative to its GUIController.
  • x, the new X position for the check box.

getX()

  • Returns the X position in pixels of the check box relative to its GUIController.

setY(int y)

  • Sets the Y position of the check box relative to its GUIController.
  • y, the new Y position for the check box.

getY()

  • Returns the Y position in pixels of the check box relative to its GUIController.

setPosition(int x, int y)

  • A convenience method to set both the X and Y position of the check box.
  • X, the new X position for the check box.
  • Y, the new Y position for the check box.

addActionListener(Object listener)

  • Adds an action listener object which receives `GUIEvent` notifications when the check box is clicked or released. You must implement the [actionPerformed()](/documentation/actionperformed/) method in order to receive events from the check box.
  • listener, the object that events are sent to. (Usually `this`.)

class="method"> isSelected()

  • Returns whether the check box is checked. The boolean value is true if the box is checked, and is false otherwise.

Example

import interfascia.*;

GUIController c;
IFCheckBox b;

void setup() {
   c = new GUIController(this);
   b = new IFCheckBox("Enable", 20, 20);

   c.add(b);
   b.addActionListener(this);
}

void draw() {
}

void actionPerformed(GUIEvent e) {
	if (e.getSource() == b) {
		if (b.isSelected()) {
			println("Checked");
		} else {
			println("Unchecked");
		}
	}
}