System News
New User-interface Control Components in JavaFX SDK 1.2
Part Two: Nodes and Buttons
May 12, 2010,
Volume 147, Issue 2

JavaFX SDK 1.2 delivers new user-interface capabilities

Users of JavaFX SDK 1.2 now have a capability previously unavailable to them in the new set of user-interface control components featured in the release. These afford not only greater portability but allow programmers to create more compelling graphical capabilities, writes Robert Eckstein in his Sun Developer Network piece "JavaFX SDK 1.2 UI Control Components: Part Two: Nodes and Buttons." Part One discussed new layout classes in JavaFX. To begin with, Eckstein points out that JavaFX UI components all inherit from the Node class, which contains a wealth of properties common to all graphical components that can work with JavaFX's scene graph, which is a set of tree data structures in which each node is either a leaf node with no sub-nodes or a branch node with possible sub-nodes. In addition, each node may or may not have a parent node. He then outlines a number of rules and characteristics taken directly from the JavaFX documentation.

Eckstein reviews the several styles, having first made some introductory comments about their common abstract superclass: javafx.scene.control.ButtonBase. He writes of ButtonBase that it attempts to consolidate functionality that is common to all buttons. In this case, ButtonBase contains one boolean property, armed, which indicates whether a mouse release on the button will cause the button's action to be invoked.

The article points out the variables present in the Button Class -- strong and action -- and goes on to observe that Button also inherits the properties of the ButtonBase and Node class. Note the addition of the strong property. The strong property is a boolean that indicates whether the Button should appear as a "stronger colored" button, perhaps to indicate to the user that it is a default button. Eckstein then presents an example, with code, of how to use the Button class.

He points out that, with the Button Class, the action property has an anonymous function attached that simply prints out a message when the button is pressed, adding that users can customize the function to perform whatever action the program deems necessary.

Up next for discussion is the CheckBox Class, of which Eckstein writes that it is a "tri-state" component: checked, unchecked, and an undefined state which indicates that its state is determined by its parent. The variables in this instance are allowTriState; Defined; and Selected, the latter two being boolean attributes that determine which of the three states CheckBox is currently in. Again, he presents examples of each of the three states.

The RadioButton Class is the next to come up for discussion. Eckstein explains that a RadioButton is a specialized form of ToggleButton that typically uses a ToggleGroup to enforce mutual exclusivity between a series of buttons. This means that only one radio button can be selected at any given time within a group. The variables in this instance are Selected and ToggleGroup. More code samples illustrate how to define a RadioButton with a ToggleGroup.

The ToggleButton Class on is another form of button, except that in this case the button will remain in the selected state until it is clicked again by the user. As with the RadioButton Class, the variables are Selected and ToggleGroup.

The Hyperlink Class is the last button class that Eckstein considers. A hyperlink is an HTML-like text label which can respond to rollovers and clicks, similar to a browser, he writes. In effect, it is a featureless button (text or image) that has an action function attached to it. The variables are visited and action. He points out that there is a visited property, which indicates whether the hyperlink should indicate if it has already been visited. Once again, the author presents code that demonstrates how to use Hyperlink.

In conclusion, Eckstein writes that the new set of user-interface (UI) control components for JavaFX programmers found in JavaFX SDK 1.2 enables developers to take advantage of the JavaFX scene graph enhances the flexibility and functionality of the Button classes. This, along with the new layout classes, enables JavaFX developers to create more compelling and portable graphical capabilities.

More Information

A Glance at the New UI Layout Control Components in JavaFX 1.2 - Part 1 of Eckstein's article series

JavaFX 1.2 Technology: Features and Enhancements

Read More ... [ more...]



Other articles in the JavaFX section of Volume 147, Issue 2:
  • New User-interface Control Components in JavaFX SDK 1.2 (this article)

See all archived articles in the JavaFX section.

Trending in
Vol 235, Issue 2
Trending IT Articles