@Override public void start(Stage stage) throws Exception { this.stage = stage; configureScene(); configureStage(); ToggleGroup tg = new ToggleGroup(); final ToggleButton tb1 = ToggleButtonBuilder.create().styleClass("graphic-toggle-button").toggleGroup(tg).graphic(buildDiseaseStatusIcon(true)).text("Not present in family").build(); tb1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if(tb1.selectedProperty().get()){ System.out.println("Selected"); }else{ System.out.println("Deselected"); } } }); ToggleButton tb2 = ToggleButtonBuilder.create().styleClass("graphic-toggle-button").toggleGroup(tg).graphic(buildDiseaseStatusIcon(false)).text("Not present in family").build(); // Logic starts HBox hb = HBoxBuilder.create().spacing(15).build(); hb.getChildren().addAll(tb1,tb2); root.getChildren().add(hb); //ScenicView.show(scene); }
private void setControl(ControlType type) { if (type == ControlType.RADIO_BUTTON) { toggleButton1 = RadioButtonBuilder.create().text("Radio button 1").id(TOGGLE_BUTTON_1_ID).build(); toggleButton2 = RadioButtonBuilder.create().text("Radio button 2").id(TOGGLE_BUTTON_2_ID).build(); } else { toggleButton1 = ToggleButtonBuilder.create().text("Toggle button 1").id(TOGGLE_BUTTON_1_ID).build(); toggleButton2 = ToggleButtonBuilder.create().text("Toggle button 2").id(TOGGLE_BUTTON_2_ID).build(); } vb1.getChildren().clear(); vb1.getChildren().addAll(toggleButton1, toggleButton2); }
/** * Builds the choice button for tables. * * @param name the toggle button name * * @return the toggle button */ private ToggleButton buildChoiceButton(final String name) { return ToggleButtonBuilder.create() .styleClass("ChoiceButton")// , "toggle-button") .alignment(Pos.BASELINE_CENTER) .minWidth(150) .minHeight(150) .maxWidth(150) .maxHeight(150) // .text(name) .build(); }
/** * Builds the choice button for game length. * * @param value the value of thez mini button * * @return the toggle button */ private ToggleButton buildMiniButton(final int value) { return ToggleButtonBuilder.create() .styleClass("MiniChoiceButton", "expr" + value)// , "toggle-button") .alignment(Pos.BASELINE_CENTER) .minWidth(70) .minHeight(70) .maxWidth(70) .maxHeight(70) .userData(value) // .text(Integer.toString(value)) .build(); }