[Up]
Launch the application via Java Web Start.
Source Code
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Button;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;
import javafx.geometry.Pos;
public class FGUIapp extends Application {
static private Button b1, b2;
static private Label lb;
static private RadioButton cb1, cb2, cb3, cb4;
static private ToggleGroup gp;
static private ComboBox cbox;
static private TextField tf;
public static void main(String args[]) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
lb = new Label("Label");
ObservableList sl =
FXCollections.observableArrayList("0", "10", "20", "30");
cbox = new ComboBox(sl);
cbox.setOnAction((ActionEvent) -> {
lb.setText("Combobox [" + cbox.getValue() + "]");
});
gp = new ToggleGroup();
cb1 = new RadioButton("Learning");
cb1.setToggleGroup(gp);
cb1.setSelected(true);
cb2 = new RadioButton("Adaptive");
cb2.setToggleGroup(gp);
cb3 = new RadioButton("H infty");
cb3.setToggleGroup(gp);
cb4 = new RadioButton("Sliding Mode");
cb4.setToggleGroup(gp);
cb1.setOnAction((ActionEvent) -> {
lb.setText("RadioButton [" + cb1.getText() + "]");
});
cb2.setOnAction((ActionEvent) -> {
lb.setText("RadioButton [" + cb2.getText() + "]");
});
cb3.setOnAction((ActionEvent) -> {
lb.setText("RadioButton [" + cb3.getText() + "]");
});
cb4.setOnAction((ActionEvent) -> {
lb.setText("RadioButton [" + cb4.getText() + "]");
});
b1 = new Button("Start");
b2 = new Button("Stop");
b1.setOnAction((ActionEvent) -> {
lb.setText("Button [" + b1.getText() + "]");
});
b2.setOnAction((ActionEvent) -> {
lb.setText("Button [" + b2.getText() + "]");
});
tf = new TextField();
tf.setOnAction((ActionEvent) -> {
lb.setText("TextField [" + tf.getText() + "]");
});
BorderPane pane = new BorderPane();
FlowPane f1 = new FlowPane();
f1.setAlignment(Pos.CENTER);
f1.setHgap(8);
f1.getChildren().add(cbox);
f1.getChildren().add(cb1);
f1.getChildren().add(cb2);
f1.getChildren().add(cb3);
f1.getChildren().add(cb4);
FlowPane f2 = new FlowPane();
f2.setAlignment(Pos.CENTER);
f2.setHgap(4);
f2.getChildren().add(b1);
f2.getChildren().add(b2);
f2.getChildren().add(tf);
pane.setTop(f1);
pane.setCenter(lb);
pane.setBottom(f2);
Scene scene = new Scene(pane, 600, 300);
stage.setTitle("FGUI app");
stage.setScene(scene);
stage.show();
}
}
naniwa@rbt.his.u-fukui.ac.jp