Im working on some card game in java. I'm using javaFX for an user inteface but i have a little problem with it. I have 25 buttons and i would like to add text to all of them. I have done it but the code is ugly and very long. I'm using scenebuilder and I created button there, every button has uniqe id from 1 to 25. Is there any way to shorten this code?
#FXML
Button card1;
#FXML
Button card2;
#FXML
Button card3;
#FXML
Button card4;
#FXML
Button card5;
#FXML
Button card6;
#FXML
Button card7;
#FXML
Button card8;
#FXML
Button card9;
#FXML
Button card10;
#FXML
Button card11;
#FXML
Button card12;
#FXML
Button card13;
#FXML
Button card14;
#FXML
Button card15;
#FXML
Button card16;
#FXML
Button card17;
#FXML
Button card18;
#FXML
Button card19;
#FXML
Button card20;
#FXML
Button card21;
#FXML
Button card22;
#FXML
Button card23;
#FXML
Button card24;
#FXML
Button card25;
#FXML
public void initialize(){
Board board = new Board();
board.createBoard();
card1.setText(board.getListFields().get(0).getWord().name());
card2.setText(board.getListFields().get(1).getWord().name());
card3.setText(board.getListFields().get(2).getWord().name());
card4.setText(board.getListFields().get(3).getWord().name());
card5.setText(board.getListFields().get(4).getWord().name());
card6.setText(board.getListFields().get(5).getWord().name());
card7.setText(board.getListFields().get(6).getWord().name());
card8.setText(board.getListFields().get(7).getWord().name());
card9.setText(board.getListFields().get(8).getWord().name());
card10.setText(board.getListFields().get(9).getWord().name());
card11.setText(board.getListFields().get(10).getWord().name());
card12.setText(board.getListFields().get(11).getWord().name());
card13.setText(board.getListFields().get(12).getWord().name());
card14.setText(board.getListFields().get(13).getWord().name());
card15.setText(board.getListFields().get(14).getWord().name());
card16.setText(board.getListFields().get(15).getWord().name());
card17.setText(board.getListFields().get(16).getWord().name());
card18.setText(board.getListFields().get(17).getWord().name());
card19.setText(board.getListFields().get(18).getWord().name());
card20.setText(board.getListFields().get(19).getWord().name());
card21.setText(board.getListFields().get(20).getWord().name());
card22.setText(board.getListFields().get(21).getWord().name());
card23.setText(board.getListFields().get(22).getWord().name());
card24.setText(board.getListFields().get(23).getWord().name());
card25.setText(board.getListFields().get(24).getWord().name());
}```
Something like is what everyone means when they say you should create those items in java and not in fxml
public class Main extends Application {
#Override
public void start(Stage primaryStage) {
GridPane gridPane = new GridPane();
//This is so you can access them later
ArrayList<Button> buttonList = new ArrayList<>();
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 5; j++) {
Button button = new Button();
button.setText("Card:"+i*j);
button.setPrefSize(80,120);
//If you need to know what card it is add the below line
button.setId(String.valueOf(i*j));
buttonList.add(button);
gridPane.add(button, i, j);
}
}
Scene scene = new Scene(gridPane);
primaryStage.setScene(scene);
primaryStage.show();
}
}
You can create a list of buttons like follows:
List<Button> buttons = Arrays.asList(card1, card2, card3, ..., card25);
Then iterate over it:
for (int i = 0; i < buttons.size(); i++) {
buttons.get(i).setText(board.getListFields().get(i).getWorld().name());
}
Related
Basically I have tableview and a FORM. I enter value in the form and they are displayed inside the table view via a database. It looks like this: FORM and TableView
When I click on the row to select it , I want to retrieve the DatePicker value from the column Begin Datum back to the Datepicker field.
I have a onMouseClicked method like this to retrieve the text/vlaues from the selected row back to the FORM
#FXML
void getSelected(MouseEvent event) {
index = tableViewBooking.getSelectionModel().getSelectedIndex();
if (index <= -1) {
return;
}
beginTime.setText(tableColSTime.getCellData(index).toString());
endTime.setText(tableColETime.getCellData(index).toString());
beginDate.setValue(tableColDate.getCellData(index).toString()); // problem has somewith with `toString()?`
reminderDesc.setText(tableColName.getCellData(index).toString());
}
Relevant primaryController code:
public class PrimaryController {
ObservableList<String> intervalList =
FXCollections.observableArrayList("Täglich","Wochelich","Monatlich");
ObservableList<String> projectTypeList = FXCollections.observableArrayList("ProjeKt Iot","Projekt Data & Analytics","Projekt SAP Intelligent Enterprise",
"Projekt Prozess & Betrieb"," Projekt Moderne Software Architekturen ");
#FXML
private DatePicker beginDate;
#FXML
private TextField beginTime;
#FXML
private Button clearButton;
#FXML
private DatePicker endDate;
#FXML
private TextField endTime;
#FXML
private TextField reminderDesc;
#FXML
private Button saveButton;
#FXML
private ComboBox cycleComboBox;
#FXML
private ComboBox projectComboBox;
#FXML
private JFXListView<String> listofdata;
#FXML
private Button modifyButton;
#FXML
private ResourceBundle resources;
#FXML
private URL url;
// Table View
#FXML
public TableView<Booking> tableViewBooking;
#FXML
public TableColumn<Booking, String> tableColName;
#FXML
public TableColumn<Booking, Double> tableColHours;
#FXML
public TableColumn<Booking, String> tableColType;
// #FXML
// public TableColumn<Booking, String> tableColProj;
#FXML
public TableColumn<Booking, String> tableColDate;
#FXML
public TableColumn<Booking, String> tableColSTime;
#FXML
public TableColumn<Booking, String> tableColETime;
int index = -1 ;
#FXML
public void initialize() throws IOException, ParseException {
cycleComboBox.setValue("Täglich");
cycleComboBox.setItems(intervalList);
projectComboBox.setValue("Projekt Moderne Software Architekturen ");
projectComboBox.setItems(projectTypeList);
System.out.println("Inside initialize");
tableColName.setCellValueFactory(new PropertyValueFactory<>("Name"));
tableColDate.setCellValueFactory(new PropertyValueFactory<>("Date"));
tableColSTime.setCellValueFactory(new PropertyValueFactory<>("startTime"));
tableColETime.setCellValueFactory(new PropertyValueFactory<>("endTime"));
tableColHours.setCellValueFactory(new PropertyValueFactory<>("Hours"));
tableColType.setCellValueFactory(new PropertyValueFactory<>("Type"));
tableViewBooking.setItems(getTableBookings());
}
the problem here is that String is undefined type for Datepicker, it is LocalDate . So what to use here instead of .toString()?
beginDate.setValue(tableColDate.getCellData(index).toString());
You should either make the tableColDate be TableColumn<Booking, LocalDate>. Then you can remove the toString() call and everything works.
The reason is that setValue() expects a LocalDate, not a String.
Or you parse the date when you are setting the DatePicker: beginDate.setValue(LocalDate.parse(tableColDate.getCellData(index))).
I am implementing a User Interface for a restaurant menu that involves a large number of increment and decrement buttons as shown below - please note I have used SceneBuilder to create the UI:
I have tried numerous methods to allow looping through each button and updating the text field next to it on mouse click but have failed to implement this via an arrayList - i keep receiving a null pointer error when i know the arraylist is succesfully filling up with the buttons.
Here is what I have tried:
I have a method which fills up the list by specifying the fxids of the appropriate buttons as so -
plusButtonList.add(soupPlus);
plusButtonList.add(guacPlus);
plusButtonList.add(empanadaPlus);
plusButtonList.add(jalapenoPlus);
plusButtonList.add(quesaPlus);
I also then have a method which is supposed to iterate through each of these buttons, setting the onaction to retrieve the current counter value from the textfield (which is also in a list but the corresponding button and text fields will be at the same indexed position) this method is called in 'initialise' in the controller class.
private void checkIfIncrement() {
for(int i = 0; i < 20; i++) {
int counter = i;
plusButtonList.get(i).setOnAction(e -> {
int currentCountVal = foodCounterList.get(counter);
theTextFields.get(counter).setText(Integer.toString(currentCountVal+ 1));
foodCounterList.set(counter, currentCountVal+1);
});
}
NOTE: foodCounterList is a list of integers containing each text field's current value. 'theTextFields' is the list containing each of the text fields.
UPDATE: Here is my Controller Class after attempting to implement the suggested improvement by Matt.
package customer;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.Pagination;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.stage.Stage;
/**
* View for the customer.
* #author Arslan Nazir
*
*/
public class CustomerView {
#FXML
private ResourceBundle resources;
#FXML
private URL location;
#FXML
private ImageView imageview;
Stage stage;
#FXML
private Button soupPlus;
#FXML
private Button soupMinus;
#FXML
private TextField soupField;
#FXML
private Button guacMinus;
#FXML
private Button guacPlus;
#FXML
private TextField guacField;
#FXML
private Font x11322;
#FXML
private Button empanadaMinus;
#FXML
private TextField empanadaField;
#FXML
private Button empanadaPlus;
#FXML
private Button jalapenoMinus;
#FXML
private Button jalapenoPlus;
#FXML
private TextField jalapenoField;
#FXML
private Button quesaMinus;
#FXML
private Button quesaPlus;
#FXML
private TextField quesaField;
#FXML
private Button choriMinus;
#FXML
private Button choriPlus;
#FXML
private TextField choriField;
#FXML
private Button seafoodMinus;
#FXML
private Button seafoodPlus;
#FXML
private TextField seafoodField;
#FXML
private Button avocadoMinus;
#FXML
private Button avocadoPlus;
#FXML
private TextField avocadoField;
#FXML
private Button burritoMinus;
#FXML
private Button burritoPlus;
#FXML
private TextField burritoField;
#FXML
private Button chilliMinus;
#FXML
private Button chilliPlus;
#FXML
private TextField chilliField;
#FXML
private Font x113221;
#FXML
private Button churrosMinus;
#FXML
private Button churrosPlus;
#FXML
private TextField churrosField;
#FXML
private Button pastelMinus;
#FXML
private Button pastelPlus;
#FXML
private TextField pastelField;
#FXML
private Button brownieMinus;
#FXML
private Button browniePlus;
#FXML
private TextField brownieField;
#FXML
private Button strawbMinus;
#FXML
private Button strawbPlus;
#FXML
private TextField strawbField;
#FXML
private Button vanillaMinus;
#FXML
private Button vanillaPlus;
#FXML
private TextField vanillaField;
#FXML
private Font x11321;
#FXML
private Button colaPlus;
#FXML
private Button colaMinus;
#FXML
private TextField colaField;
#FXML
private Button dietColaMinus;
#FXML
private Button dietColaPlus;
#FXML
private TextField dietColaField;
#FXML
private Button mojitoMinus;
#FXML
private Button mojitoPlus;
#FXML
private TextField mojitoField;
#FXML
private Button blueMargMinus;
#FXML
private Button blueMargPlus;
#FXML
private TextField blueMargField;
#FXML
private Button redMargMinus;
#FXML
private Button redMargPlus;
#FXML
private TextField redMargField;
#FXML
private Button bottleWaterMinus;
#FXML
private Button bottleWaterPlus;
#FXML
private TextField bottleWaterField;
#FXML
private Button tapWaterMinus;
#FXML
private Button tapWaterPlus;
#FXML
private TextField tapWaterField;
#FXML
private Button closeprogram;
#FXML
private Button minimiseprogram;
#FXML
private VBox bgone;
#FXML
private Button callwaiter;
#FXML
private TextField summaryField;
static List<TextField> theTextFields = new ArrayList<>();
ArrayList<Button> plusButtonList = new ArrayList<>(Arrays.asList(soupPlus, guacPlus));
static List<Button> minusButtonList = new ArrayList<>();
static List<Integer> foodCounterList = new ArrayList<>();
public void listPopulate() {
theTextFields.add(soupField);
theTextFields.add(guacField);
theTextFields.add(empanadaField);
theTextFields.add(jalapenoField);
theTextFields.add(quesaField);
theTextFields.add(choriField);
theTextFields.add(seafoodField);
theTextFields.add(avocadoField);
theTextFields.add(burritoField);
theTextFields.add(chilliField);
theTextFields.add(churrosField);
theTextFields.add(pastelField);
theTextFields.add(brownieField);
theTextFields.add(strawbField);
theTextFields.add(vanillaField);
theTextFields.add(colaField);
theTextFields.add(dietColaField);
theTextFields.add(mojitoField);
theTextFields.add(blueMargField);
theTextFields.add(redMargField);
theTextFields.add(bottleWaterField);
theTextFields.add(tapWaterField);
for (int i = 0; i< theTextFields.size(); i++) {
theTextFields.get(i).setText("0");
}
minusButtonList.add(soupMinus);
minusButtonList.add(guacMinus);
minusButtonList.add(empanadaMinus);
minusButtonList.add(jalapenoMinus);
minusButtonList.add(quesaMinus);
minusButtonList.add(choriMinus);
minusButtonList.add(seafoodMinus);
minusButtonList.add(avocadoMinus);
minusButtonList.add(burritoMinus);
minusButtonList.add(chilliMinus);
minusButtonList.add(churrosMinus);
minusButtonList.add(pastelMinus);
minusButtonList.add(brownieMinus);
minusButtonList.add(strawbMinus);
minusButtonList.add(vanillaMinus);
minusButtonList.add(colaMinus);
minusButtonList.add(dietColaMinus);
minusButtonList.add(mojitoMinus);
minusButtonList.add(blueMargMinus);
minusButtonList.add(redMargMinus);
minusButtonList.add(bottleWaterMinus);
minusButtonList.add(tapWaterMinus);
/**
plusButtonList[0] = soupPlus;
plusButtonList[1] = guacPlus;
plusButtonList[2] = empanadaPlus;
plusButtonList[3] = soupPlus;
plusButtonList[4] = soupPlus;
plusButtonList[5] = soupPlus;
plusButtonList[6] = soupPlus;
plusButtonList[7] = soupPlus;
plusButtonList[8] = soupPlus;
plusButtonList[9] = soupPlus;
plusButtonList[10] = soupPlus;
plusButtonList[11] = soupPlus;
plusButtonList[12] = soupPlus;
plusButtonList[13] = soupPlus;
plusButtonList[14] = soupPlus;
plusButtonList[15] = soupPlus;
plusButtonList[16] = soupPlus;
plusButtonList[17] = soupPlus;
plusButtonList[18] = soupPlus;
plusButtonList[19] = soupPlus;
plusButtonList[20] = soupPlus;
plusButtonList[21] = soupPlus;
plusButtonList[22] = soupPlus;
plusButtonList.add(soupPlus);
plusButtonList.add(guacPlus);
plusButtonList.add(empanadaPlus);
plusButtonList.add(jalapenoPlus);
plusButtonList.add(quesaPlus);
plusButtonList.add(choriPlus);
plusButtonList.add(seafoodPlus);
plusButtonList.add(avocadoPlus);
plusButtonList.add(burritoPlus);
plusButtonList.add(chilliPlus);
plusButtonList.add(churrosPlus);
plusButtonList.add(pastelPlus);
plusButtonList.add(browniePlus);
plusButtonList.add(strawbPlus);
plusButtonList.add(vanillaPlus);
plusButtonList.add(colaPlus);
plusButtonList.add(dietColaPlus);
plusButtonList.add(mojitoPlus);
plusButtonList.add(blueMargPlus);
plusButtonList.add(redMargPlus);
plusButtonList.add(bottleWaterPlus);
plusButtonList.add(tapWaterPlus);
**/
foodCounterList.add(Integer.parseInt(soupField.getText()));
foodCounterList.add(Integer.parseInt(guacField.getText()));
foodCounterList.add(Integer.parseInt(empanadaField.getText()));
foodCounterList.add(Integer.parseInt(jalapenoField.getText()));
foodCounterList.add(Integer.parseInt(quesaField.getText()));
foodCounterList.add(Integer.parseInt(choriField.getText()));
foodCounterList.add(Integer.parseInt(seafoodField.getText()));
foodCounterList.add(Integer.parseInt(avocadoField.getText()));
foodCounterList.add(Integer.parseInt(burritoField.getText()));
foodCounterList.add(Integer.parseInt(chilliField.getText()));
foodCounterList.add(Integer.parseInt(churrosField.getText()));
foodCounterList.add(Integer.parseInt(pastelField.getText()));
foodCounterList.add(Integer.parseInt(brownieField.getText()));
foodCounterList.add(Integer.parseInt(strawbField.getText()));
foodCounterList.add(Integer.parseInt(vanillaField.getText()));
foodCounterList.add(Integer.parseInt(colaField.getText()));
foodCounterList.add(Integer.parseInt(dietColaField.getText()));
foodCounterList.add(Integer.parseInt(mojitoField.getText()));
foodCounterList.add(Integer.parseInt(blueMargField.getText()));
foodCounterList.add(Integer.parseInt(redMargField.getText()));
foodCounterList.add(Integer.parseInt(bottleWaterField.getText()));
foodCounterList.add(Integer.parseInt(tapWaterField.getText()));
}
private void checkIfIncrement() {
for (int i = 0; i < theTextFields.size(); i++) {
setButtonActionsForFoodItem(plusButtonList.get(i), theTextFields.get(i));
}
}
private void setButtonActionsForFoodItem(Button plusButton, TextField textField) {
plusButton.setOnAction(event -> {
int currentValue = Integer.parseInt(textField.getText());
textField.setText(String.valueOf(++currentValue));
});
}
/**for(int i =0; i < plusButtonList.size(); i++) {
int counter = i;
plusButtonList.get(i).setOnMouseClicked(new EventHandler<MouseEvent>() {
#Override
public void handle(MouseEvent t) {
int currentCountVal = foodCounterList.get(counter);
theTextFields.get(counter).setText(Integer.toString(currentCountVal+ 1));
foodCounterList.set(counter, currentCountVal+1);
}
});
}**/
#FXML
private void handleCloseProgram(ActionEvent event) {
stage = (Stage)((Button)event.getSource()).getScene().getWindow();
stage.close();
System.exit(1);
}
#FXML
private void handleMinimiseProgram(ActionEvent event) {
stage = (Stage)((Button)event.getSource()).getScene().getWindow();
stage.setIconified(true);
}
#FXML
public void handle(ActionEvent event) {
}
#FXML
void initialize() {
//ButtonAndCountLists.setCounters();
listPopulate();
//System.out.println(plusButtonList.get(21));
System.out.println(foodCounterList.get(1));
checkIfIncrement();
}
}
First of all, I don't understand why you are using static lists in this solution? In that case I think they should be just marked as private.
Next I don't think that method "checkIfIncrement" has proper name for what it is doing. From your code I suppose it should be named setButtonsListeners()?
Did you put proper fx:id="exampleName" on increment/decrement buttons in you FXML file ? Maybe it is causing NPE. Please paste fxml file here with error stacktrace.
So I had a similar issue. I was trying to get a specific button to trigger a specific event depending on which button was clicked out of the array list. Here was my solution, I tried using .isPressed() first but that always returned false, so I changed it to isArmed() and that worked. Maybe you can try that? My code is written below.
serveButtons was the arrayList that contained all of the different buttons.
orderContentsList was the arrayList that contained the textAreas to be changed.
int which = 0;
for (int i = 0; i < serveButtons.size(); i++) {
if (serveButtons.get(i).isArmed()) {
which = i;
break;
}
}
orderContentsList.get(which).setText(null);
If you need any more information about the arrayLists then let me know.
This question already has answers here:
Passing Parameters JavaFX FXML
(10 answers)
javafx 8 compatibility issues - FXML static fields
(1 answer)
Closed 3 years ago.
I'm building a rock, scissors, paper application as a college homework. I should use radio-buttons and since it's a game, it should allows one selected button at a time.
I tried to create ToggleGroups and set one of the buttons as selected by default, but it's not working! When I run the application, it still allows me to choose more than one button :(
What am I missing?
public class Main extends Application {
#Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("../view/QuilometrosPorLitroView.fxml"));
primaryStage.setTitle("Pedra, Papel, Tesoura");
primaryStage.setScene(new Scene(root, 428, 336));
primaryStage.setResizable(false);
primaryStage.show();
Controller.selectButtonDefault();
}
public static void main(String[] args) {
launch(args);
}
}
public class Controller {
#FXML
public static
RadioButton tesoura = new RadioButton();
#FXML
public static
RadioButton pedra = new RadioButton();
#FXML
public static
RadioButton papel = new RadioButton();
public static void selectButtonDefault() {
ToggleGroup group = new ToggleGroup();
tesoura.setToggleGroup(group);
tesoura.setSelected(true);
pedra.setToggleGroup(group);
papel.setToggleGroup(group);
}
This
#FXML public static RadioButton tesoura = new RadioButton();
#FXML public static RadioButton pedra = new RadioButton();
#FXML public static RadioButton papel = new RadioButton();
Should be changed into
#FXML private RadioButton tesoura;
#FXML private RadioButton pedra;
#FXML private RadioButton papel;
I'm trying to make an imitation of TV screen using java, javaFX and scenebulider. Right now I'm able to play the video but I don't know how to make it off at first, then after a button press it's going to play.
Here's my Controller code
public class Controller implements Initializable {
#FXML
private Slider suwak2;
#FXML
private Slider suwak5;
#FXML
private Slider suwak1;
#FXML
private Slider suwak4;
#FXML
private Slider suwak6;
#FXML
private Slider suwak3;
#FXML
private ToggleButton wlacznik;
#FXML
private MediaView mv;
private MediaPlayer mp;
private Media me;
#Override
public void initialize(URL location, ResourceBundle resources)
{
String path=new File("src/application/lol.mp4").getAbsolutePath();
Path clip = new Path(new MoveTo(50, 400), new ArcTo(50, 200, 0, 50, 0, false, true), new HLineTo(450), new ArcTo(50, 200, 0, 350, 400, false, true), new ClosePath());
clip.setFill(Color.BLACK);
clip.setStroke(null);
mv.setClip(clip);
me = new Media(new File(path).toURI().toString());
mp = new MediaPlayer(me);
mv.setMediaPlayer(mp);
mp.setAutoPlay(true);
mp.setCycleCount(MediaPlayer.INDEFINITE);
suwak1.setValue(mp.getVolume() * 100);
suwak1.valueProperty().addListener(new InvalidationListener() {
#Override
public void invalidated(Observable observable) {
mp.setVolume(suwak1.getValue()/100);
}
});
}
}
suwak1 is my volume slider, wlacznik is my toogle button to make it on and off.
Maybe you need a Button for Play/Stop
Button stop = new Button("STOP");
stop.setOnAction((e) -> mp.stop());
Button play = new Button("Play");
play.setOnAction((e) -> mp.play());
Can someone tell me why there is a delay on Checkbox initialization with my Code?
What happens is that if I open the program, I have to click the Checkbox several times until it performes the desired Action.
The Controller also contains setter and getter methods.
Thanks a lot
public class Controller {
/* Defined variables */
#FXML
private CheckBox happyboxtick;
#FXML
private VBox topbox;
#FXML
private VBox designbox;
#FXML
public void initialize(){
happyboxtick.setSelected(true);
designbox.setVisible(false);
designbox.getChildren().removeAll();
topbox.setVisible(true);
topbox.getChildren().addAll();
}
#FXML
public void doSomething(ActionEvent e) {
//final CheckBox chk1 = new CheckBox("chk 1");
//final CheckBox chk2 = new CheckBox("chk 2");
EventHandler eh = new EventHandler<ActionEvent>() {
#Override
public void handle(ActionEvent event) {
if (event.getSource() instanceof CheckBox) {
CheckBox chk = (CheckBox) event.getSource();
//System.out.println("Action performed on checkbox " + chk.getText());
//System.out.println(chk);
if(chk.isSelected()){
System.out.println("My box is selected.");
topbox.setVisible(false);
topbox.getChildren().removeAll();
designbox.setVisible(true);
designbox.getChildren().addAll();
} else
{
System.out.println("My box is not selected.");
topbox.setVisible(true);
topbox.getChildren().addAll();
designbox.setVisible(false);
designbox.getChildren().removeAll();
}/*
if ("Yes".equals(chk.getText())) {
chk2.setSelected(!chk1.isSelected());
} else if ("chk 2".equals(chk.getText())) {
chk1.setSelected(!chk2.isSelected());
}*/
}
}
};
happyboxtick.setOnAction(eh);
//chk1.setOnAction(eh);
//chk2.setOnAction(eh);
}
}
The Code compiles perfectly.
Initialization works.
The right Option is selected.
But when I click the box, I may have to click several times until the Elements are shown. And I don't know why.