this post was submitted on 20 Jul 2023
3 points (100.0% liked)

JavaFX

116 readers
1 users here now

JavaFX is a software platform and a graphical user interface (GUI) toolkit that allows developers to create rich and interactive applications for desktop, mobile, and embedded devices. It provides a powerful set of tools and APIs for building modern, visually appealing applications.

JavaFX was introduced as a successor to the Swing framework. It is designed to provide a more advanced and flexible way of developing user interfaces compared to Swing, with improved graphics and multimedia capabilities.

Rules

  1. No NSFW/NSFL content
  2. No service requests/offers
  3. Must be JavaFX related
  4. No politics

founded 1 year ago
MODERATORS
3
Creating a Custom Skin (www.pragmaticcoding.ca)
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/[email protected]
 

I have a blog where I talk about programming stuff - mostly JavaFX and Kotlin. I've been trying to keep up a steady stream of new content, and I have lots of ideas for topics, but sometimes life gets in the way. This is the first article I've posted in a couple of months.

This latest article is the last in a set of three about creating custom controls in JavaFX. The first two were:

They're not actually required reading for this last article, but they do cover, between them, the most common use cases and approaches for creating custom controls.

But if you've ever wondered what Skin was, and how you might alter the look and feel of one of the standard JavaFX controls, then this article might be for you. In it, I look at turning the standard JavaFX ToggleButton into a toggle switch (with a flipper). Under the hood, it's still a ToggleButton, but by reskinning it, it has a whole new look and feel.

This whole area around Skins and Skinnable is pretty arcane in the JavaFX world. There are very few articles about how to do it. So a word of warning here, everything I know I found out by poking into the source code, looking at other people's attempts and digging into the little I could find on the web. This is not an explanation of any "official" documentation about how to do this - so there may be some mistakes in the approach. I can say that it works, and it works well.

As far as I can tell, this is the clearest (in my opinion, at least), step-by-step breakdown of how to go about creating a skin that's available. It's still not for beginners, but I hope someone finds it useful.

If not, then read the first two articles, I think they're pretty good too.

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here