Search…
Switch

Overview

Switch is a element that chooses between two proportions
SwitchSample.java
1
// Instance a simple switch
2
subtitles = new Switch();
3
4
// Set the colors up
5
subtitles.colorBallOn = Color.getRGB(0,150,136);
6
subtitles.colorBarOn = Colors.P_700;
7
subtitles.colorBallOn = Color.getRGB(241,241,241);
8
subtitles.colorBarOff = Colors.P_200;
9
10
// Positions the switch
11
add(subtitles, RIGHT-hGap, SAME+lsfx.getHeight()/2, PREFERRED, PREFERRED);
Copied!
This sample code is only from the Switch, to see the complete sample, including the Slider, go to github

Attributes

Type
Name
Description
boolean
centerText
Boolean that center the text instead of move from left to right
int
colorBackOff
Background color for off switch
int
colorBackOn
Background color for on switch
int
colorForeOff
Foreground color for off switch
int
colorForeOn
Foreground color for on switch
String
textBackOff
Background text for off switch
String
textBackOn
Background text for on switch
String
textForeOff
Foreground text for off switch
String
textForeOn
Foreground text for on switch

Methods

Type
Name
Description
Constructor
Switch( )
Creates a simple switch
int
getPreferredHeight( )
Returns the switch minimum height
int
getPreferredWidth( )
Returns the switch minimum width
boolean
isOn( )
Return true if the switch is on
void
moveSwitch(boolean toLeft)
If true, move the switch to left
void
setOn(boolean b)
If true, turn on the switch
void
setPos(int x, int y)
Set the Switch´s x and y position

References

Last modified 1yr ago