Its long time since I blogged and lot of things happened during that time – Release of JavaFX 1.2, Java Store, New Samples… and lot more to write about!
Let me start with UI Controls…
Following are some of the UI controls – Button, CheckBox, Hyperlink, Label, ListView, ProgressBar, ProgressIndicator, RadioButton, ScrollBar, Slider, TextBox, ToggleButton
The article on Node-Based Controls demonstrates its usage. So let me focus on how to update the skin of these controls.
The skin attribute of Control class allows you to associate a Skin. The Skin is responsible for implementing the user interface using on scene-graph nodes and defining the behavior of the control. The Behavior has the logic for handling key and mouse events.
Sounds complicated? confused? Control, Skin, Behavior.. For now lets look at a simple and straight forward way to just change the color and some basic attributes of Skin.
JavaFX already has a default skin implementation – Caspian. Its in com.sun.javafx.scene.control.caspian package. For each control, there is corresponding skin implementation. We can change few attributes of these skin implementations and customize the look of controls.
Example: To update skin of Button, we can customize the attributes of ButtonSkin implementation.
|
Similarly a TextBox can be customized as shown below:
|
More attributes and implementation is available in the source.
Try it out and let me know feedback!
Source:

0 Responses to “JavaFX – Skinnable Controls”