Legal Terms and Copyright Notice
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
* Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
* Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.
*
* 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,
trademark notice, this list of conditions, and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
trademark notice, this list of conditions, and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* * Neither the name of Oracle 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.
*/
package controls;
import javafx.scene.Scene;
import javafx.scene.control.Button;
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.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.text.Font;
import javafx.animation.Timeline;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.LayoutInfo;
import javafx.ext.swing.SwingButton;
import javafx.scene.shape.Rectangle;
var angle: Number;
Timeline {
repeatCount: Timeline.INDEFINITE
autoReverse: false
keyFrames: [
at (0s) {angle => 0.0},
at (4s) {angle => 360.0}
]
}.play();
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 {
fill: Color.web("#dbe9fd")
width: 310
height: 400
content:
VBox {
translateX: 10
translateY: 10
spacing: 20
content: [
HBox {
spacing: 5
content: bind [
Label {
text: "TextBox:"
}
TextBox {}
]
}
HBox {
spacing: 5
content: bind [
Label {
text: "Button:"
}
Button { text: "OK" translateY: 10 strong: true font: Font{size: 10 name: "Tahoma"} rotate: bind angle}
Button { translateX: 20
//layoutInfo: LayoutInfo { width: 150 }
graphic:
ImageView{image:
Image{url: "{__DIR__}dukewave.jpg"}}
//Image{url: "http://java.sun.com/docs/books/tutorial/images/DukeWave.gif"}}
}
]
}
HBox {
spacing: 5
content: bind [
Label {
text: "ToggleButton:"
}
ToggleButton { toggleGroup: group1 text: "Selected" selected: true }
ToggleButton { toggleGroup: group1 text: "Rotated" rotate: 90 }
ToggleButton { toggleGroup: group1 text: "Flashed" opacity: bind opacityLevel}
]
}
HBox {
spacing: 5
content: bind [
Label {
text: "RadioButton:"
}
RadioButton { toggleGroup: group2 text: "First" selected: true}
// skin: Rectangle{}}
RadioButton { toggleGroup: group2 text: "Second" translateY: 10}
RadioButton { toggleGroup: group2 text: "Third" translateY: 20
}
]
}
HBox {
spacing: 5
content: bind [
Label {
text: "CheckBox:"
}
CheckBox { text: "Normal" }
CheckBox { text: "Checked" selected: true }
CheckBox { allowTriState: true text: "Undefined" defined: false }
]
}
HBox {
spacing: 5
content: bind [
Label {
text: "Slider:"
}
slider
]
}
HBox {
spacing: 5
content: bind [
Label {
text: "ProgressBar:"
}
VBox{
content: [
ProgressBar { progress: bind slider.value / slider.max }
ProgressBar { progress: -1 }
]
}
]
}
HBox {
spacing: 5
content: bind [
Label {
text: "ProgressIndicator:"
}
ProgressIndicator { progress: bind slider.value / slider.max }
ProgressIndicator { progress: -1 }
]
}
]//content of VBox
}//VBox
}//Scene
}//Stage