DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • Integration Testing Tutorial: A Comprehensive Guide With Examples And Best Practices
  • How To Use Pandas and Matplotlib To Perform EDA In Python
  • What Is JHipster?
  • The Role of AI and Programming in the Gaming Industry: A Look Beyond the Tables

Trending

  • Integration Testing Tutorial: A Comprehensive Guide With Examples And Best Practices
  • How To Use Pandas and Matplotlib To Perform EDA In Python
  • What Is JHipster?
  • The Role of AI and Programming in the Gaming Industry: A Look Beyond the Tables
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Toggle Switch for Java

Toggle Switch for Java

Pedro Duque Vieira user avatar by
Pedro Duque Vieira
·
Jul. 06, 14 · Interview
Like (0)
Save
Tweet
Share
6.27K Views

Join the DZone community and get the full member experience.

Join For Free

a toggle switch is a control that is very popular, especially on touch based devices. you can see it in android:

switches_switches

in ios (6 and 7):

ios-7-toggle-switch1

and in windows 8:

toggle-sync-setting-in-windows8

functionally it works just like a check-box but for touch devices it has one big advantage: when your finger is over the touch device it won’t obscure the control and so you can see an instant feedback when you press it. the disadvantage is obviously that this control takes up more space.

implementation

my implementation of the toggle switch allows you to change the text for the on and off state that appears right next to the toggle switch. you can also style the control using just css. it comes with a css implementation that gives it a metro look.

demo

below you can see a live demonstration of the control, in a light and a dark theme.

toggleswitch_lighttheme.gif

toggle switch (jmetro light theme)

toggle switch (jmetro dark theme)

toggle switch (jmetro dark theme)

you can grab the control and the accompanying metro style css by going to the jfxtras repository.

further developments

currently it’s still not possible to style the toggle switch to look like the android toggle switch using just css because it’s not possible to specify that the on and off text should appear inside the control and not outside as in the case of metro. i’d also like to add the possibility to turn the animation on or off through css.

about these ads
Java (programming language) Implementation Light (web browser) Android (robot) IT ADS (motorcycle) Advantage (cryptography) Grab (software) Repository (version control)

Published at DZone with permission of Pedro Duque Vieira, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • Integration Testing Tutorial: A Comprehensive Guide With Examples And Best Practices
  • How To Use Pandas and Matplotlib To Perform EDA In Python
  • What Is JHipster?
  • The Role of AI and Programming in the Gaming Industry: A Look Beyond the Tables

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: