Toggle Switch for java


A Toggle Switch is a control that is very popular, especially on touch based devices. You can see it in Android:


In iOS (6 and 7):


And in Windows 8:


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.


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.


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


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.


Moving on…

Image by Mundilfari

On July 1st I’ll be no longer working full time with Modellus and as a consequence with JavaFX. I will however continue to work on it as an hobby, Modellus 5 is almost complete and I wish on having a very usable version on September.
From that point one, I preview Modellus will start to evolve at a quick pace taking advantage of the change of swing to javafx.

Despite some flawed features and omissions I’ve grown to like JavaFX very much, I think its based on solid concepts and will grow to become a very powerful language. I hope somewhere in the future I can continue working with it at a professional level..

Modellus 5 brief demo

If you’ve seen my first blog post: You’ll know what Modellus is.

Today I want to show a very brief demo of the upcoming Modellus 5. It is written in JavaFX and Swing.

Kirill’s talk on animations: gave me the idea of making this demo about the movement of physical objects. Bear in mind that this is still in beta stage.

So on to the demo video:

Have a good weekend. 🙂

Hello world!

Hello, my name is Pedro I’m a software engineer and this is my first blog post ever.

As for my job, I’m currently working as a researcher on a University in Portugal, developing Modellus, a free software for modelling physics and mathematics:, (The current version 4.5 will be available this week). Also made a small contribution to JFxtras – JXScene for javafx1.2 (also thanks to Andrew Hughes).

Modellus is primarily used to aid teaching. By using only a mathematical language (no need to learn any new language) students and teachers are able to create models which then they can interact/view using animations/graphs/tables, etc.

On the previous months I’ve been porting Modellus 4.5 – a swing application – to javafx. As a mid step I’ve embedded the animation part made in javafx onto the rest.

Modellus 5 will be finalized and released till the end of April since, sadly for me, that is the time when the project will suffer an halt because to this date we weren’t able to get more funds.

So to wrap it all up this blog will be about my lessons learned while porting Modellus to JavaFX.