<dependency>
<groupId>com.vaadin.addon</groupId>
<artifactId>vaadin-onoffswitch</artifactId>
<version>${project.version}</version>
</dependency>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
final OnOffSwitch onoffSwitch = new OnOffSwitch(false);
// Vaadin8
onOffSwitch.addValueChangeListener(event -> {
boolean checked = event.getValue();
System.out.println("OnOffSwitch checked : " + checked);
});
// Vaadin7
onoffSwitch.addValueChangeListener(new ValueChangeListener(){
@Override
public void valueChange(ValueChangeEvent event) {
boolean checked = (boolean) event.getProperty().getValue();
System.out.println("onoffSwitch checked : " + checked);
}
});
$green: #40b527;
.onoffswitch-slider.on {
background-color: $green;
border-color: $green;
}
.onoffswitch-slider.on:before {
border-color: $green;
}
Linux/Mac
sh mvnw clean install
sh mvnw -pl onoffswitch-demo jetty:run
Windows
mvnw.cmd clean install
mvnw.cmd -pl onoffswitch-demo jetty:run
Demo Server : http://127.0.0.1:8080
requires Java SE 1.7.0_79+
requires Maven 3.3.9+
requires Tomcat 8.0.36+
requires Eclipse Mars.2 4.5.2+
requires Vaadin Framework 7.7.3+