Java Code Examples for javafx.scene.control.RadioButton#setSelected()
The following examples show how to use
javafx.scene.control.RadioButton#setSelected() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RadioButtons.java From marathonv5 with Apache License 2.0 | 7 votes |
public RadioButtons() { super(400,100); ToggleGroup tg = new ToggleGroup(); VBox vbox = new VBox(); vbox.setSpacing(5); RadioButton rb1 = new RadioButton("Hello"); rb1.setToggleGroup(tg); RadioButton rb2 = new RadioButton("Bye"); rb2.setToggleGroup(tg); rb2.setSelected(true); RadioButton rb3 = new RadioButton("Disabled"); rb3.setToggleGroup(tg); rb3.setSelected(false); rb3.setDisable(true); vbox.getChildren().add(rb1); vbox.getChildren().add(rb2); vbox.getChildren().add(rb3); getChildren().add(vbox); }
Example 2
Source File: RadioButtons.java From marathonv5 with Apache License 2.0 | 6 votes |
public RadioButtons() { super(400,100); ToggleGroup tg = new ToggleGroup(); VBox vbox = new VBox(); vbox.setSpacing(5); RadioButton rb1 = new RadioButton("Hello"); rb1.setToggleGroup(tg); RadioButton rb2 = new RadioButton("Bye"); rb2.setToggleGroup(tg); rb2.setSelected(true); RadioButton rb3 = new RadioButton("Disabled"); rb3.setToggleGroup(tg); rb3.setSelected(false); rb3.setDisable(true); vbox.getChildren().add(rb1); vbox.getChildren().add(rb2); vbox.getChildren().add(rb3); getChildren().add(vbox); }
Example 3
Source File: AttributeNodeProvider.java From constellation with Apache License 2.0 | 5 votes |
@Override public void setContent(final Tab tab) { GraphManager.getDefault().addGraphManagerListener(this); newActiveGraph(GraphManager.getDefault().getActiveGraph()); final TextField filterText = new TextField(); filterText.setPromptText("Filter attribute names"); final ToggleGroup tg = new ToggleGroup(); final RadioButton startsWithRb = new RadioButton("Starts with"); startsWithRb.setToggleGroup(tg); startsWithRb.setPadding(new Insets(0, 0, 0, 5)); startsWithRb.setSelected(true); final RadioButton containsRb = new RadioButton("Contains"); containsRb.setToggleGroup(tg); containsRb.setPadding(new Insets(0, 0, 0, 5)); tg.selectedToggleProperty().addListener((ov, oldValue, newValue) -> { filter(table, filterText.getText(), startsWithRb.isSelected()); }); filterText.textProperty().addListener((ov, oldValue, newValue) -> { filter(table, newValue, startsWithRb.isSelected()); }); final HBox headerBox = new HBox(new Label("Filter: "), filterText, startsWithRb, containsRb); headerBox.setAlignment(Pos.CENTER_LEFT); headerBox.setPadding(new Insets(5)); final VBox box = new VBox(schemaLabel, headerBox, table); VBox.setVgrow(table, Priority.ALWAYS); Platform.runLater(() -> { tab.setContent(box); }); }
Example 4
Source File: CurlExporter.java From milkman with MIT License | 5 votes |
@Override public Node getRoot(RequestContainer request, Templater templater) { this.request = request; textArea = new TextArea(); textArea.setEditable(false); HBox osSelection = new HBox(); ToggleGroup group = new ToggleGroup(); RadioButton windowsTgl = new RadioButton("Windows"); windowsTgl.setToggleGroup(group); windowsTgl.setSelected(isWindows); RadioButton unixTgl = new RadioButton("Unix"); unixTgl.setSelected(!isWindows); unixTgl.setToggleGroup(group); windowsTgl.selectedProperty().addListener((obs, o, n) -> { if (n != null) { isWindows = n; refreshCommand(templater); } }); osSelection.getChildren().add(windowsTgl); osSelection.getChildren().add(unixTgl); VBox root = new VBox(); root.getChildren().add(osSelection); root.getChildren().add(textArea); VBox.setVgrow(textArea, Priority.ALWAYS); refreshCommand(templater); return root; }
Example 5
Source File: FxmlControl.java From MyBox with Apache License 2.0 | 5 votes |
public static boolean setRadioFirstSelected(ToggleGroup group) { if (group == null) { return false; } ObservableList<Toggle> buttons = group.getToggles(); for (Toggle button : buttons) { RadioButton radioButton = (RadioButton) button; radioButton.setSelected(true); return true; } return false; }
Example 6
Source File: JavaFXToggleButtonElementTest.java From marathonv5 with Apache License 2.0 | 5 votes |
@Test public void selectRadioBottonSelectedSelected() { RadioButton radioButtonNode = (RadioButton) getPrimaryStage().getScene().getRoot().lookup(".radio-button"); radioButtonNode.setSelected(true); AssertJUnit.assertEquals(true, radioButtonNode.isSelected()); radioButton.marathon_select("true"); new Wait("Waiting for the radio button selection.") { @Override public boolean until() { return radioButtonNode.isSelected(); } }; }
Example 7
Source File: TSpectrumSample.java From chart-fx with Apache License 2.0 | 4 votes |
private ToolBar getTopToolBar() { ToolBar toolBar = new ToolBar(); ToggleGroup radioGroup = new ToggleGroup(); RadioButton bbqButton1 = new RadioButton("LHC BBQ spectrum"); bbqButton1.setSelected(true); bbqButton1.setToggleGroup(radioGroup); toolBar.getItems().add(bbqButton1); bbqButton1.selectedProperty().addListener((ch, o, n) -> { if (Boolean.FALSE.equals(n)) { return; } demoDataSet.set(readDemoData(SOURCE1)); }); RadioButton bbqButton2 = new RadioButton("CPS BBQ spectrum"); bbqButton2.setToggleGroup(radioGroup); toolBar.getItems().add(bbqButton2); bbqButton2.selectedProperty().addListener((ch, o, n) -> { if (Boolean.FALSE.equals(n)) { return; } demoDataSet.set(new MathDataSet(null, DataSetMath::magnitudeSpectrumDecibel, readDemoData(SOURCE2))); }); RadioButton bbqButton3 = new RadioButton("LHC injection BBQ spectrum"); bbqButton3.setToggleGroup(radioGroup); toolBar.getItems().add(bbqButton3); bbqButton3.selectedProperty().addListener((ch, o, n) -> { if (Boolean.FALSE.equals(n)) { return; } demoDataSet.set(new MathDataSet(null, DataSetMath::magnitudeSpectrumDecibel, readDemoData(SOURCE3))); }); RadioButton synthButton = new RadioButton("synthetic spectrum"); Slider slider = new Slider(10, 8192, 512); slider.setBlockIncrement(10); slider.valueProperty().addListener((ch, o, n) -> { if (synthButton.isSelected()) { demoDataSet.set(generateDemoSineWaveData(n.intValue())); } }); synthButton.setToggleGroup(radioGroup); toolBar.getItems().add(synthButton); synthButton.selectedProperty().addListener((ch, o, n) -> { if (Boolean.FALSE.equals(n)) { return; } demoDataSet.set(generateDemoSineWaveData((int) slider.getValue())); }); toolBar.getItems().add(slider); return toolBar; }
Example 8
Source File: FailureNoteVBoxer.java From marathonv5 with Apache License 2.0 | 4 votes |
private ToolBar createButtonBar(boolean selectable, boolean editable) { ToolBar toolBar = new ToolBar(); label = new Label(item.getLabel()); ToggleGroup toggleGroup = new ToggleGroup(); success = new RadioButton("Success"); fail = new RadioButton("Fail"); notes = new RadioButton("Notes"); success.setDisable(!editable); fail.setDisable(!editable); notes.setDisable(!editable); success.selectedProperty().addListener((observable, oldValue, newValue) -> { if (success.isSelected()) { item.setSelected(1); } textArea.setDisable(success.isSelected()); }); fail.selectedProperty().addListener((observable, oldValue, newValue) -> { if (fail.isSelected()) { item.setSelected(3); } textArea.setDisable(success.isSelected()); }); notes.selectedProperty().addListener((observable, oldValue, newValue) -> { if (notes.isSelected()) { item.setSelected(2); } textArea.setDisable(success.isSelected()); }); int selected = item.getSelected(); if (selected == 1) { success.setSelected(true); } else if (selected == 3) { fail.setSelected(true); } else if (selected == 2) { notes.setSelected(true); } else { success.setSelected(editable); } toggleGroup.getToggles().addAll(success, fail, notes); Region region = new Region(); HBox.setHgrow(region, Priority.ALWAYS); toolBar.getItems().addAll(label, region, success, fail, notes); return toolBar; }
Example 9
Source File: SearchView.java From phoebus with Eclipse Public License 1.0 | 4 votes |
/** Create search view * * <p>While technically a {@link SplitPane}, * should be treated as generic {@link Node}, * using only the API defined in here * * @param model * @param undo */ public SearchView(final Model model, final UndoableActionManager undo) { this.model = model; this.undo = undo; // Archive List // Pattern: ____________ [Search] pattern.setTooltip(new Tooltip(Messages.SearchPatternTT)); pattern.setMaxWidth(Double.MAX_VALUE); HBox.setHgrow(pattern, Priority.ALWAYS); final Button search = new Button(Messages.Search); search.setTooltip(new Tooltip(Messages.SearchTT)); final HBox search_row = new HBox(5.0, new Label(Messages.SearchPattern), pattern, search); search_row.setAlignment(Pos.CENTER_LEFT); pattern.setOnAction(event -> searchForChannels()); search.setOnAction(event -> searchForChannels()); // ( ) Add .. (x) Replace search result final RadioButton result_add = new RadioButton(Messages.AppendSearchResults); result_add.setTooltip(new Tooltip(Messages.AppendSearchResultsTT)); result_replace = new RadioButton(Messages.ReplaceSearchResults); result_replace.setTooltip(new Tooltip(Messages.ReplaceSearchResultsTT)); final ToggleGroup result_handling = new ToggleGroup(); result_add.setToggleGroup(result_handling); result_replace.setToggleGroup(result_handling); result_replace.setSelected(true); final HBox replace_row = new HBox(5.0, result_add, result_replace); replace_row.setAlignment(Pos.CENTER_RIGHT); // PV Name | Source // ---------+-------- // | final TableColumn<ChannelInfo, String> pv_col = new TableColumn<>(Messages.PVName); pv_col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().getName())); pv_col.setReorderable(false); channel_table.getColumns().add(pv_col); final TableColumn<ChannelInfo, String> archive_col = new TableColumn<>(Messages.ArchiveName); archive_col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().getArchiveDataSource().getName())); archive_col.setReorderable(false); channel_table.getColumns().add(archive_col); channel_table.setPlaceholder(new Label(Messages.SearchPatternTT)); // PV name column uses most of the space, archive column the rest pv_col.prefWidthProperty().bind(channel_table.widthProperty().multiply(0.8)); archive_col.prefWidthProperty().bind(channel_table.widthProperty().subtract(pv_col.widthProperty())); channel_table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); VBox.setVgrow(channel_table, Priority.ALWAYS); search_row.setPadding(new Insets(5, 5, 0, 5)); replace_row.setPadding(new Insets(5, 5, 0, 5)); final VBox bottom = new VBox(5, search_row, replace_row, channel_table); setOrientation(Orientation.VERTICAL); getItems().setAll(archive_list, bottom); setDividerPositions(0.2f); final ContextMenu menu = new ContextMenu(); channel_table.setContextMenu(menu); channel_table.setOnContextMenuRequested(this::updateContextMenu); setupDrag(); Platform.runLater(() -> pattern.requestFocus()); }
Example 10
Source File: ForceDirectedGraphTest.java From charts with Apache License 2.0 | 4 votes |
private void initializeParts(){ dataGenerator = new DataGenerator(); dataGenerator.generateGraphWithMinimalInformation(); nodeEdgeModel = new NodeEdgeModel(dataGenerator.getNodes(), dataGenerator.getEdges()); nodeEdgeModel.addColorTheme(createExampleColorTheme(),"Example_1"); nodeEdgeModel.addColorTheme(createExampleColorTheme2(), "Example_2"); nodeEdgeModel.setCurrentColorThemeKey("Kelly Color"); graphPanel = new GraphPanel(nodeEdgeModel); sliderBox = new VBox(); nodeSizeFactor = new Slider(5,30,10); edgeWidthFactor = new Slider(0.5,10,5); groupComboBox = new ComboBox<>(); nodeValueComboBox = new ComboBox<>(); edgeForceValueComboBox = new ComboBox<>(); edgeWidthValueComboBox = new ComboBox<>(); colorSchemeComboBox = new ComboBox<>(); colorSchemeComboBox.getItems().addAll(graphPanel.getNodeEdgeModel().getColorThemeKeys()); normalizeGroup = new ToggleGroup(); alwaysNormalize = new RadioButton("Always Normalize"); neverNormalize = new RadioButton("Never Normalize"); normalizeIfBetweenZeroAndOne = new RadioButton("Normalize if Between 0 and 1"); alwaysNormalize.setToggleGroup(normalizeGroup); neverNormalize.setToggleGroup(normalizeGroup); normalizeIfBetweenZeroAndOne.setToggleGroup(normalizeGroup); alwaysNormalize.setSelected(true); physic = new CheckBox("Disable Physics"); physic.selectedProperty().setValue(true); invertedForce = new CheckBox("inverted"); calculateDegreeCentrality = new Button("Calculate Degreecentrality"); calculateClosenessCentrality = new Button("Calculate ClossenessCentrality"); calculateBetweennessCentrality = new Button("Calculate BetweennessCentrality"); restartAnimation = new Button("Restart Animation"); borderColorPicker = new ColorPicker(); edgeColorPicker = new ColorPicker(); edgeColorPicker.setValue(Color.LIGHTGRAY); groupComboBox.getItems().addAll(graphPanel.getNodeEdgeModel().getStringAttributeKeysOfNodes()); nodeValueComboBox.getItems().addAll(graphPanel.getNodeEdgeModel().getNumericAttributeKeysOfNodes()); edgeForceValueComboBox.getItems().addAll(graphPanel.getNodeEdgeModel().getNumericAttributeKeysOfEdges()); edgeWidthValueComboBox.getItems().addAll(graphPanel.getNodeEdgeModel().getNumericAttributeKeysOfEdges()); //edgeForceValueComboBox.getItems().addAll(nodeEdgeModel) dataChanger = new ComboBox<>(); dataChanger.getItems().addAll("D3Example","FoodExport"); colors = new VBox(); refreshColorPickers(); }
Example 11
Source File: ChooseCameraControllerSample.java From arcgis-runtime-samples-java with Apache License 2.0 | 4 votes |
@Override public void start(Stage stage){ try { // create stack pane and JavaFX app scene StackPane stackPane = new StackPane(); Scene fxScene = new Scene(stackPane); fxScene.getStylesheets().add(getClass().getResource("/choose_camera_controller/style.css").toExternalForm()); // set title, size, and add JavaFX scene to stage stage.setTitle("Choose Camera Controller Sample"); stage.setWidth(800); stage.setHeight(700); stage.setScene(fxScene); stage.show(); // create a scene and add a basemap to it ArcGISScene scene = new ArcGISScene(); scene.setBasemap(Basemap.createImagery()); // set the scene to a scene view sceneView = new SceneView(); sceneView.setArcGISScene(scene); // add base surface for elevation data Surface surface = new Surface(); ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource("https://elevation3d.arcgis" + ".com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"); surface.getElevationSources().add(elevationSource); scene.setBaseSurface(surface); // create a graphics overlay for the scene GraphicsOverlay sceneGraphicsOverlay = new GraphicsOverlay(); sceneView.getGraphicsOverlays().add(sceneGraphicsOverlay); // create a graphic with a ModelSceneSymbol of a plane to add to the scene String modelURI = new File(System.getProperty("data.dir"), "./samples-data/bristol/Collada/Bristol.dae").getAbsolutePath(); ModelSceneSymbol plane3DSymbol = new ModelSceneSymbol(modelURI, 1.0); plane3DSymbol.loadAsync(); plane3DSymbol.setHeading(45); Graphic plane3D = new Graphic(new Point(-109.937516, 38.456714, 5000, SpatialReferences.getWgs84()), plane3DSymbol); sceneGraphicsOverlay.getSceneProperties().setSurfacePlacement(LayerSceneProperties.SurfacePlacement.ABSOLUTE); sceneGraphicsOverlay.getGraphics().add(plane3D); // create a camera and set it as the viewpoint for when the scene loads Camera camera = new Camera(38.459291, -109.937576, 5500, 150.0, 20.0, 0.0); sceneView.setViewpointCamera(camera); // instantiate a new camera controller which orbits the plane at a set distance OrbitGeoElementCameraController orbitPlaneCameraController = new OrbitGeoElementCameraController(plane3D, 100.0); orbitPlaneCameraController.setCameraPitchOffset(30); orbitPlaneCameraController.setCameraHeadingOffset(150); // instantiate a new camera controller which orbits a target location Point locationPoint = new Point(-109.929589, 38.437304, 1700, SpatialReferences.getWgs84()); OrbitLocationCameraController orbitLocationCameraController = new OrbitLocationCameraController(locationPoint, 5000); orbitLocationCameraController.setCameraPitchOffset(3); orbitLocationCameraController.setCameraHeadingOffset(150); // create radio buttons for choosing camera controller RadioButton orbitPlane = new RadioButton("ORBIT CAMERA AROUND PLANE"); RadioButton orbitLocation = new RadioButton("ORBIT CAMERA AROUND CRATER"); RadioButton globeCamera = new RadioButton("FREE PAN ROUND THE GLOBE"); globeCamera.setSelected(true); // set the buttons to a toggle group ToggleGroup toggleGroup = new ToggleGroup(); orbitPlane.setToggleGroup(toggleGroup); orbitLocation.setToggleGroup(toggleGroup); globeCamera.setToggleGroup(toggleGroup); // set the radio buttons to choose which camera controller is active orbitPlane.setOnAction(event -> sceneView.setCameraController(orbitPlaneCameraController)); orbitLocation.setOnAction(event -> sceneView.setCameraController(orbitLocationCameraController)); globeCamera.setOnAction(event -> sceneView.setCameraController(new GlobeCameraController())); // create a control panel VBox controlsVBox = new VBox(10); controlsVBox.setBackground(new Background(new BackgroundFill(Paint.valueOf("rgba(0, 0, 0, 0.3)"), CornerRadii.EMPTY, Insets.EMPTY))); controlsVBox.setPadding(new Insets(10.0)); controlsVBox.setMaxSize(300, 80); controlsVBox.getStyleClass().add("panel-region"); // add radio buttons to the control panel controlsVBox.getChildren().addAll(orbitPlane, orbitLocation, globeCamera); // add scene view, label and control panel to the stack pane stackPane.getChildren().addAll(sceneView, controlsVBox); StackPane.setAlignment(controlsVBox, Pos.TOP_LEFT); StackPane.setMargin(controlsVBox, new Insets(60, 0, 0, 20)); } catch (Exception e) { // on any exception, print the stack trace e.printStackTrace(); } }
Example 12
Source File: JavaFxSelectionComponentFactory.java From triplea with GNU General Public License v3.0 | 4 votes |
ProxySetting( final ClientSetting<HttpProxy.ProxyChoice> proxyChoiceClientSetting, final ClientSetting<String> proxyHostClientSetting, final ClientSetting<Integer> proxyPortClientSetting) { this.proxyChoiceClientSetting = proxyChoiceClientSetting; this.proxyHostClientSetting = proxyHostClientSetting; this.proxyPortClientSetting = proxyPortClientSetting; final HttpProxy.ProxyChoice proxyChoice = proxyChoiceClientSetting.getValueOrThrow(); noneButton = new RadioButton("None"); noneButton.setSelected(proxyChoice == HttpProxy.ProxyChoice.NONE); systemButton = new RadioButton("Use System Settings"); systemButton.setSelected(proxyChoice == HttpProxy.ProxyChoice.USE_SYSTEM_SETTINGS); userButton = new RadioButton("Use These Settings:"); userButton.setSelected(proxyChoice == HttpProxy.ProxyChoice.USE_USER_PREFERENCES); hostText = new TextField(proxyHostClientSetting.getValue().orElse("")); portText = new TextField(proxyPortClientSetting.getValue().map(Object::toString).orElse("")); final VBox radioPanel = new VBox(); radioPanel .getChildren() .addAll( noneButton, systemButton, userButton, new Label("Proxy Host: "), hostText, new Label("Proxy Port: "), portText); hostText.disableProperty().bind(Bindings.not(userButton.selectedProperty())); portText.disableProperty().bind(Bindings.not(userButton.selectedProperty())); final ToggleGroup toggleGroup = new ToggleGroup(); noneButton.setToggleGroup(toggleGroup); systemButton.setToggleGroup(toggleGroup); userButton.setToggleGroup(toggleGroup); toggleGroup .selectedToggleProperty() .addListener( (observable, oldValue, newValue) -> { if (!userButton.isSelected()) { hostText.clear(); portText.clear(); } }); getChildren().add(radioPanel); }
Example 13
Source File: Exercise_16_06.java From Intro-to-Java-Programming with MIT License | 4 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Set properties for text fields tfTextField.setText("JavaFX"); tfTextField.setAlignment(Pos.BOTTOM_CENTER); tfColumnSize.setAlignment(Pos.BOTTOM_RIGHT); tfColumnSize.setPrefColumnCount(3); tfTextField.setPrefColumnCount(12); tfColumnSize.setText("12"); // Create three radio buttions RadioButton rbLeft = new RadioButton("Left"); RadioButton rbCenter = new RadioButton("Center"); RadioButton rbRight = new RadioButton("Right"); rbCenter.setSelected(true); // Create a toggle group ToggleGroup group = new ToggleGroup(); rbLeft.setToggleGroup(group); rbCenter.setToggleGroup(group); rbRight.setToggleGroup(group); // Create four hbox HBox paneForRadioButtons = new HBox(5); paneForRadioButtons.getChildren().addAll(rbLeft, rbCenter, rbRight); paneForRadioButtons.setAlignment(Pos.BOTTOM_LEFT); HBox paneForColumnSize = new HBox(5); paneForColumnSize.getChildren().addAll( new Label("Colum Size"), tfColumnSize); HBox paneForTextField = new HBox(5); paneForTextField.setAlignment(Pos.CENTER); paneForTextField.getChildren().addAll( new Label("Text Field"), tfTextField); HBox hbox = new HBox(10); hbox.getChildren().addAll(paneForRadioButtons, paneForColumnSize); // Create a vBox and place nodes in it VBox pane = new VBox(10); pane.setPadding(new Insets(5, 5, 5, 5)); pane.getChildren().addAll(paneForTextField, hbox); // Create and register the handlers rbLeft.setOnAction(e -> { if (rbLeft.isSelected()) { tfTextField.setAlignment(Pos.BOTTOM_LEFT); } }); rbCenter.setOnAction(e -> { if (rbCenter.isSelected()) { tfTextField.setAlignment(Pos.BOTTOM_CENTER); } }); rbRight.setOnAction(e -> { if (rbRight.isSelected()) { tfTextField.setAlignment(Pos.BOTTOM_RIGHT); } }); tfColumnSize.setOnKeyPressed(e -> { if (e.getCode() == KeyCode.ENTER) { tfTextField.setPrefColumnCount(Integer.parseInt( tfColumnSize.getText())); } }); // Create a scene and place it in the stage Scene scene = new Scene(pane); primaryStage.setTitle("Exercise_16_06"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 14
Source File: Exercise_16_03.java From Intro-to-Java-Programming with MIT License | 4 votes |
@Override // Override the start method in the Application calss public void start(Stage primaryStage) { // Create a vbox VBox paneForCircles = new VBox(5); paneForCircles.setAlignment(Pos.CENTER); // Create three circles Circle c1 = getCircle(); Circle c2 = getCircle(); Circle c3 = getCircle(); c1.setFill(Color.RED); // Place circles in vbox paneForCircles.getChildren().addAll(c1, c2, c3); // Create a rectangle Rectangle rectangle = new Rectangle(); rectangle.setFill(Color.WHITE); rectangle.setWidth(30); rectangle.setHeight(100); rectangle.setStroke(Color.BLACK); rectangle.setStrokeWidth(2); StackPane stopSign = new StackPane(rectangle, paneForCircles); // Create a hbox HBox paneForRadioButtons = new HBox(5); paneForRadioButtons.setAlignment(Pos.CENTER); // Create radio buttons RadioButton rbRed = new RadioButton("Red"); RadioButton rbYellow = new RadioButton("Yellow"); RadioButton rbGreen = new RadioButton("Green"); // Create a toggle group ToggleGroup group = new ToggleGroup(); rbRed.setToggleGroup(group); rbYellow.setToggleGroup(group); rbGreen.setToggleGroup(group); rbRed.setSelected(true); paneForRadioButtons.getChildren().addAll(rbRed, rbYellow, rbGreen); // Create a border pane BorderPane pane = new BorderPane(); pane.setCenter(stopSign); pane.setBottom(paneForRadioButtons); // Create and register handlers rbRed.setOnAction(e -> { if (rbRed.isSelected()) { c1.setFill(Color.RED); c2.setFill(Color.WHITE); c3.setFill(Color.WHITE); } }); rbYellow.setOnAction(e -> { if (rbYellow.isSelected()) { c1.setFill(Color.WHITE); c2.setFill(Color.YELLOW); c3.setFill(Color.WHITE); } }); rbGreen.setOnAction(e -> { if (rbGreen.isSelected()) { c1.setFill(Color.WHITE); c2.setFill(Color.WHITE); c3.setFill(Color.GREEN); } }); // Create a scene and place it in the stage Scene scene = new Scene(pane, 200, 150); primaryStage.setTitle("Exercise_16_03"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }