Java Reference
In-Depth Information
Figure 10.4
The JavaFX Weather Widget
The widget's GUI is a JavaFX scene that contains a group of three main compo-
nents: title text, a progress bar, and a vertical box that contains the individual
weather text components. Some of the code for this is shown in Listing 10.6. The
progress bar remains hidden until a request is made to a REST service, at which
point it's made visible and is activated. When all of the requested data is
received, it's hidden again.
Listing 10.6
The Weather Widget Scene Structure
var app: VBox;
// ...
var scene: Scene = Scene {
content: Group {
content: bind [
// Widget title text
Text {
content: bind "Current Weather for {location.city}"
font: Font { size: 20 }
textOrigin: TextOrigin.TOP
translateX:
bind (stage.width-titleText.layoutBounds.width)
/ 2.0 + titleText.layoutBounds.minX
y: 5
}
// Progress bar
bar = IndeterminateProgressBar {
translateY: bind stage.height - 20;
continues
Search WWH ::




Custom Search