/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * Copyright 2009 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. * * This file is available and licensed under the following license: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Sun Microsystems nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import javafx.scene.Scene; import javafx.scene.control.CheckBox; import javafx.scene.control.Label; import javafx.scene.control.ProgressBar; import javafx.scene.control.ProgressIndicator; import javafx.scene.control.RadioButton; import javafx.scene.control.Slider; import javafx.scene.control.TextBox; import javafx.scene.control.ToggleButton; import javafx.scene.control.ToggleGroup; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.stage.Stage; import javafx.animation.Timeline; import javafx.scene.control.Hyperlink; var opacityLevel: Number; Timeline { repeatCount: Timeline.INDEFINITE autoReverse: false keyFrames: [ at (0s) {opacityLevel => 0.2}, at (2s) {opacityLevel => 1.0} at (4s) {opacityLevel => 0.2} ] }.play(); var group1 = ToggleGroup{}; var group2 = ToggleGroup{}; def slider = Slider { max: 100 } Stage { title: "Controls (JavaFX sample)" scene: Scene { width: 510 height: 400 content: VBox {translateX: 10 translateY: 10 spacing: 20 content: [ HBox {spacing: 5 content: [ Label {text: "RadioButton:"} VBox{ content:[ RadioButton { toggleGroup: group2 text: "First" selected: true } RadioButton { toggleGroup: group2 text: "Second" } ] } Label {text: "TextBox:"} TextBox {} ] } HBox {spacing: 5 content: [ Label {text: "ToggleButton:"} ToggleButton { toggleGroup: group1 text: "Yes" selected: true } ToggleButton { toggleGroup: group1 text: "No" } ToggleButton { toggleGroup: group1 text: "I don't know" opacity: bind opacityLevel } ] } HBox {spacing: 5 content: [ Label {text: "CheckBox:"} CheckBox { text: "Normal" } CheckBox { text: "Checked" selected: true } CheckBox { allowTriState: true text: "Undefined" defined: false } ] } HBox {spacing: 5 content: [ Label {text: "Slider:"} slider, Label {text: "Hyperlink:"} Hyperlink { text: "javafx.com"} ] } HBox {spacing: 5 content: [ Label {text: "ProgressBar:"} VBox{ content: [ HBox { content: [ ProgressBar { progress: bind slider.value / slider.max }, ProgressIndicator { progress: bind slider.value / slider.max } ] } HBox { content: [ ProgressBar { progress: -1 }, ProgressIndicator { progress: -1 } ] } ] } ] } ]//content of VBox }//VBox }//Scene }//Stage