JavaFX example: ToggleGroup |
package javafx_togglegroup; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.ToggleButton; import javafx.scene.control.ToggleGroup; import javafx.scene.layout.HBox; import javafx.stage.Stage; /** * * @web http://java-buddy.blogspot.com/ */ public class JavaFX_ToggleGroup extends Application { @Override public void start(Stage primaryStage) { ToggleButton toggleButton1 = new ToggleButton("Button 1"); ToggleButton toggleButton2 = new ToggleButton("Button 2"); ToggleButton toggleButton3 = new ToggleButton("Button 3"); ToggleGroup toggleGroup = new ToggleGroup(); toggleButton1.setToggleGroup(toggleGroup); toggleButton2.setToggleGroup(toggleGroup); toggleButton3.setToggleGroup(toggleGroup); HBox hBox = new HBox(); hBox.getChildren().addAll(toggleButton1, toggleButton2, toggleButton3); Group root = new Group(); root.getChildren().add(hBox); Scene scene = new Scene(root, 300, 250); primaryStage.setTitle("java-buddy.blogspot.com"); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
No comments:
Post a Comment