JAVAFX CheckBox thread











up vote
0
down vote

favorite












I have a list of Japanese dishes and the user select which dish will commande. I'm trying to check which ones of the Checkboxes are selected from a thread and print the price in a Label but when I run my code it returns NullPointerException



here is my code:



int price=0;

@FXML private Label textPrice;

//Dishes
@FXML private CheckBox salade;
@FXML private CheckBox soupeMiso;
@FXML private CheckBox soupe_miso_EBI;

public void threadPrice() {
new Thread(new Runnable() {
@Override public void run() {
Platform.runLater(new Runnable() {
@Override public void run() {
//selectedSushi() ;

if(salade.isSelected()) {
System.out.println("salade selected");
price=price+Sushi.SALADE.getPrice();
}

if(soupeMiso.isSelected()) {
price=price+Sushi.SOUPE_MISOU.getPrice();
}

if(soupe_miso_EBI.isSelected()) {
price=price+Sushi.SOUPE_MISOU_EBI.getPrice();
}


}
});

}}).start();


String strPrice = Integer.toString(price);
textPrice.setText("price:"+strPrice);
}




 <?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>

<AnchorPane xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MenuController">
<children>
<AnchorPane prefHeight="486.0" prefWidth="617.0">
<children>
<HBox layoutX="195.0" layoutY="10.0" prefHeight="49.0" prefWidth="193.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="MENU" textAlignment="CENTER" wrappingWidth="195.6796875">
<font>
<Font size="52.0" />
</font>*
</Text>
</children>
</HBox>
<HBox layoutX="25.0" layoutY="160.0" prefHeight="26.0" prefWidth="578.0">
<children>
<CheckBox fx:id="soupeMiso" mnemonicParsing="false" text="Soupe Miso">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</CheckBox>
<CheckBox fx:id="salade1" mnemonicParsing="false" text="Salade">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</CheckBox>
<CheckBox fx:id="soupe_miso_EBI" mnemonicParsing="false" text="Supe Miso EBI">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</CheckBox>
</children>
</HBox>
<HBox layoutX="25.0" layoutY="275.0" prefHeight="26.0" prefWidth="578.0" />
<Label fx:id="textPrice" layoutX="204.0" layoutY="393.0" prefHeight="44.0" prefWidth="196.0" text="price:">
<font>
<Font size="38.0" />
</font>
</Label>
<Button fx:id="order" layoutX="215.0" layoutY="358.0" mnemonicParsing="false" onAction="#selectedSushi" text="ORDER" />
</children>
</AnchorPane>





Error:



 Exception in thread "JavaFX Application Thread"   
java.lang.NullPointerException
at application.MenuController$1$1.run(MenuController.java:143)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$48(GtkApplication.java:139)
at java.lang.Thread.run(Thread.java:748)









share|improve this question









New contributor




Asmaa MOHAMEDI is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • How is the threadPrice invoked? How is the object you call this for created, how do you load the fxml and how does the fxml look (The parts with the CheckBoxes and possibly the Node using threadPrice as event handler seem to of interest here.) Furthermore what are you trying to achieve using a Thread here? It's most likely that the CheckBoxes do not change between calling the threadPrice method and the execution of the runnable used with Platform.runLater.
    – fabian
    2 days ago










  • You get the NullPointerException at this line String strPrice = Integer.toString(price); ?
    – Bo Halim
    2 days ago










  • the issue is in salade.isSelected that returns null, i change the code and create a methode without thread like that: @FXML private void selectedSushi(ActionEvent event) { System.out.println("Check box"); if(salade.isSelected()) { System.out.println("salade selected"); price=price+Sushi.SALADE.getPrice(); } if(soupeMiso.isSelected()) { price=price+Sushi.SOUPE_MISOU.getPrice(); } if(soupe_miso_EBI.isSelected()) { price=price+Sushi.SOUPE_MISOU_EBI.getPrice(); } String prix= Integer.toString(price); textPrice.setText("Prix:"+prix);}
    – Asmaa MOHAMEDI
    2 days ago












  • and it doesnt work, isSelected always returs null
    – Asmaa MOHAMEDI
    2 days ago










  • Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
    – kleopatra
    2 days ago















up vote
0
down vote

favorite












I have a list of Japanese dishes and the user select which dish will commande. I'm trying to check which ones of the Checkboxes are selected from a thread and print the price in a Label but when I run my code it returns NullPointerException



here is my code:



int price=0;

@FXML private Label textPrice;

//Dishes
@FXML private CheckBox salade;
@FXML private CheckBox soupeMiso;
@FXML private CheckBox soupe_miso_EBI;

public void threadPrice() {
new Thread(new Runnable() {
@Override public void run() {
Platform.runLater(new Runnable() {
@Override public void run() {
//selectedSushi() ;

if(salade.isSelected()) {
System.out.println("salade selected");
price=price+Sushi.SALADE.getPrice();
}

if(soupeMiso.isSelected()) {
price=price+Sushi.SOUPE_MISOU.getPrice();
}

if(soupe_miso_EBI.isSelected()) {
price=price+Sushi.SOUPE_MISOU_EBI.getPrice();
}


}
});

}}).start();


String strPrice = Integer.toString(price);
textPrice.setText("price:"+strPrice);
}




 <?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>

<AnchorPane xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MenuController">
<children>
<AnchorPane prefHeight="486.0" prefWidth="617.0">
<children>
<HBox layoutX="195.0" layoutY="10.0" prefHeight="49.0" prefWidth="193.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="MENU" textAlignment="CENTER" wrappingWidth="195.6796875">
<font>
<Font size="52.0" />
</font>*
</Text>
</children>
</HBox>
<HBox layoutX="25.0" layoutY="160.0" prefHeight="26.0" prefWidth="578.0">
<children>
<CheckBox fx:id="soupeMiso" mnemonicParsing="false" text="Soupe Miso">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</CheckBox>
<CheckBox fx:id="salade1" mnemonicParsing="false" text="Salade">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</CheckBox>
<CheckBox fx:id="soupe_miso_EBI" mnemonicParsing="false" text="Supe Miso EBI">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</CheckBox>
</children>
</HBox>
<HBox layoutX="25.0" layoutY="275.0" prefHeight="26.0" prefWidth="578.0" />
<Label fx:id="textPrice" layoutX="204.0" layoutY="393.0" prefHeight="44.0" prefWidth="196.0" text="price:">
<font>
<Font size="38.0" />
</font>
</Label>
<Button fx:id="order" layoutX="215.0" layoutY="358.0" mnemonicParsing="false" onAction="#selectedSushi" text="ORDER" />
</children>
</AnchorPane>





Error:



 Exception in thread "JavaFX Application Thread"   
java.lang.NullPointerException
at application.MenuController$1$1.run(MenuController.java:143)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$48(GtkApplication.java:139)
at java.lang.Thread.run(Thread.java:748)









share|improve this question









New contributor




Asmaa MOHAMEDI is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • How is the threadPrice invoked? How is the object you call this for created, how do you load the fxml and how does the fxml look (The parts with the CheckBoxes and possibly the Node using threadPrice as event handler seem to of interest here.) Furthermore what are you trying to achieve using a Thread here? It's most likely that the CheckBoxes do not change between calling the threadPrice method and the execution of the runnable used with Platform.runLater.
    – fabian
    2 days ago










  • You get the NullPointerException at this line String strPrice = Integer.toString(price); ?
    – Bo Halim
    2 days ago










  • the issue is in salade.isSelected that returns null, i change the code and create a methode without thread like that: @FXML private void selectedSushi(ActionEvent event) { System.out.println("Check box"); if(salade.isSelected()) { System.out.println("salade selected"); price=price+Sushi.SALADE.getPrice(); } if(soupeMiso.isSelected()) { price=price+Sushi.SOUPE_MISOU.getPrice(); } if(soupe_miso_EBI.isSelected()) { price=price+Sushi.SOUPE_MISOU_EBI.getPrice(); } String prix= Integer.toString(price); textPrice.setText("Prix:"+prix);}
    – Asmaa MOHAMEDI
    2 days ago












  • and it doesnt work, isSelected always returs null
    – Asmaa MOHAMEDI
    2 days ago










  • Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
    – kleopatra
    2 days ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a list of Japanese dishes and the user select which dish will commande. I'm trying to check which ones of the Checkboxes are selected from a thread and print the price in a Label but when I run my code it returns NullPointerException



here is my code:



int price=0;

@FXML private Label textPrice;

//Dishes
@FXML private CheckBox salade;
@FXML private CheckBox soupeMiso;
@FXML private CheckBox soupe_miso_EBI;

public void threadPrice() {
new Thread(new Runnable() {
@Override public void run() {
Platform.runLater(new Runnable() {
@Override public void run() {
//selectedSushi() ;

if(salade.isSelected()) {
System.out.println("salade selected");
price=price+Sushi.SALADE.getPrice();
}

if(soupeMiso.isSelected()) {
price=price+Sushi.SOUPE_MISOU.getPrice();
}

if(soupe_miso_EBI.isSelected()) {
price=price+Sushi.SOUPE_MISOU_EBI.getPrice();
}


}
});

}}).start();


String strPrice = Integer.toString(price);
textPrice.setText("price:"+strPrice);
}




 <?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>

<AnchorPane xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MenuController">
<children>
<AnchorPane prefHeight="486.0" prefWidth="617.0">
<children>
<HBox layoutX="195.0" layoutY="10.0" prefHeight="49.0" prefWidth="193.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="MENU" textAlignment="CENTER" wrappingWidth="195.6796875">
<font>
<Font size="52.0" />
</font>*
</Text>
</children>
</HBox>
<HBox layoutX="25.0" layoutY="160.0" prefHeight="26.0" prefWidth="578.0">
<children>
<CheckBox fx:id="soupeMiso" mnemonicParsing="false" text="Soupe Miso">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</CheckBox>
<CheckBox fx:id="salade1" mnemonicParsing="false" text="Salade">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</CheckBox>
<CheckBox fx:id="soupe_miso_EBI" mnemonicParsing="false" text="Supe Miso EBI">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</CheckBox>
</children>
</HBox>
<HBox layoutX="25.0" layoutY="275.0" prefHeight="26.0" prefWidth="578.0" />
<Label fx:id="textPrice" layoutX="204.0" layoutY="393.0" prefHeight="44.0" prefWidth="196.0" text="price:">
<font>
<Font size="38.0" />
</font>
</Label>
<Button fx:id="order" layoutX="215.0" layoutY="358.0" mnemonicParsing="false" onAction="#selectedSushi" text="ORDER" />
</children>
</AnchorPane>





Error:



 Exception in thread "JavaFX Application Thread"   
java.lang.NullPointerException
at application.MenuController$1$1.run(MenuController.java:143)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$48(GtkApplication.java:139)
at java.lang.Thread.run(Thread.java:748)









share|improve this question









New contributor




Asmaa MOHAMEDI is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I have a list of Japanese dishes and the user select which dish will commande. I'm trying to check which ones of the Checkboxes are selected from a thread and print the price in a Label but when I run my code it returns NullPointerException



here is my code:



int price=0;

@FXML private Label textPrice;

//Dishes
@FXML private CheckBox salade;
@FXML private CheckBox soupeMiso;
@FXML private CheckBox soupe_miso_EBI;

public void threadPrice() {
new Thread(new Runnable() {
@Override public void run() {
Platform.runLater(new Runnable() {
@Override public void run() {
//selectedSushi() ;

if(salade.isSelected()) {
System.out.println("salade selected");
price=price+Sushi.SALADE.getPrice();
}

if(soupeMiso.isSelected()) {
price=price+Sushi.SOUPE_MISOU.getPrice();
}

if(soupe_miso_EBI.isSelected()) {
price=price+Sushi.SOUPE_MISOU_EBI.getPrice();
}


}
});

}}).start();


String strPrice = Integer.toString(price);
textPrice.setText("price:"+strPrice);
}




 <?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>

<AnchorPane xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MenuController">
<children>
<AnchorPane prefHeight="486.0" prefWidth="617.0">
<children>
<HBox layoutX="195.0" layoutY="10.0" prefHeight="49.0" prefWidth="193.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="MENU" textAlignment="CENTER" wrappingWidth="195.6796875">
<font>
<Font size="52.0" />
</font>*
</Text>
</children>
</HBox>
<HBox layoutX="25.0" layoutY="160.0" prefHeight="26.0" prefWidth="578.0">
<children>
<CheckBox fx:id="soupeMiso" mnemonicParsing="false" text="Soupe Miso">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</CheckBox>
<CheckBox fx:id="salade1" mnemonicParsing="false" text="Salade">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</CheckBox>
<CheckBox fx:id="soupe_miso_EBI" mnemonicParsing="false" text="Supe Miso EBI">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</CheckBox>
</children>
</HBox>
<HBox layoutX="25.0" layoutY="275.0" prefHeight="26.0" prefWidth="578.0" />
<Label fx:id="textPrice" layoutX="204.0" layoutY="393.0" prefHeight="44.0" prefWidth="196.0" text="price:">
<font>
<Font size="38.0" />
</font>
</Label>
<Button fx:id="order" layoutX="215.0" layoutY="358.0" mnemonicParsing="false" onAction="#selectedSushi" text="ORDER" />
</children>
</AnchorPane>





Error:



 Exception in thread "JavaFX Application Thread"   
java.lang.NullPointerException
at application.MenuController$1$1.run(MenuController.java:143)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$48(GtkApplication.java:139)
at java.lang.Thread.run(Thread.java:748)






java multithreading javafx checkbox nullpointerexception






share|improve this question









New contributor




Asmaa MOHAMEDI is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Asmaa MOHAMEDI is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago









Zephyr

3,1091928




3,1091928






New contributor




Asmaa MOHAMEDI is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









Asmaa MOHAMEDI

12




12




New contributor




Asmaa MOHAMEDI is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Asmaa MOHAMEDI is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Asmaa MOHAMEDI is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • How is the threadPrice invoked? How is the object you call this for created, how do you load the fxml and how does the fxml look (The parts with the CheckBoxes and possibly the Node using threadPrice as event handler seem to of interest here.) Furthermore what are you trying to achieve using a Thread here? It's most likely that the CheckBoxes do not change between calling the threadPrice method and the execution of the runnable used with Platform.runLater.
    – fabian
    2 days ago










  • You get the NullPointerException at this line String strPrice = Integer.toString(price); ?
    – Bo Halim
    2 days ago










  • the issue is in salade.isSelected that returns null, i change the code and create a methode without thread like that: @FXML private void selectedSushi(ActionEvent event) { System.out.println("Check box"); if(salade.isSelected()) { System.out.println("salade selected"); price=price+Sushi.SALADE.getPrice(); } if(soupeMiso.isSelected()) { price=price+Sushi.SOUPE_MISOU.getPrice(); } if(soupe_miso_EBI.isSelected()) { price=price+Sushi.SOUPE_MISOU_EBI.getPrice(); } String prix= Integer.toString(price); textPrice.setText("Prix:"+prix);}
    – Asmaa MOHAMEDI
    2 days ago












  • and it doesnt work, isSelected always returs null
    – Asmaa MOHAMEDI
    2 days ago










  • Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
    – kleopatra
    2 days ago


















  • How is the threadPrice invoked? How is the object you call this for created, how do you load the fxml and how does the fxml look (The parts with the CheckBoxes and possibly the Node using threadPrice as event handler seem to of interest here.) Furthermore what are you trying to achieve using a Thread here? It's most likely that the CheckBoxes do not change between calling the threadPrice method and the execution of the runnable used with Platform.runLater.
    – fabian
    2 days ago










  • You get the NullPointerException at this line String strPrice = Integer.toString(price); ?
    – Bo Halim
    2 days ago










  • the issue is in salade.isSelected that returns null, i change the code and create a methode without thread like that: @FXML private void selectedSushi(ActionEvent event) { System.out.println("Check box"); if(salade.isSelected()) { System.out.println("salade selected"); price=price+Sushi.SALADE.getPrice(); } if(soupeMiso.isSelected()) { price=price+Sushi.SOUPE_MISOU.getPrice(); } if(soupe_miso_EBI.isSelected()) { price=price+Sushi.SOUPE_MISOU_EBI.getPrice(); } String prix= Integer.toString(price); textPrice.setText("Prix:"+prix);}
    – Asmaa MOHAMEDI
    2 days ago












  • and it doesnt work, isSelected always returs null
    – Asmaa MOHAMEDI
    2 days ago










  • Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
    – kleopatra
    2 days ago
















How is the threadPrice invoked? How is the object you call this for created, how do you load the fxml and how does the fxml look (The parts with the CheckBoxes and possibly the Node using threadPrice as event handler seem to of interest here.) Furthermore what are you trying to achieve using a Thread here? It's most likely that the CheckBoxes do not change between calling the threadPrice method and the execution of the runnable used with Platform.runLater.
– fabian
2 days ago




How is the threadPrice invoked? How is the object you call this for created, how do you load the fxml and how does the fxml look (The parts with the CheckBoxes and possibly the Node using threadPrice as event handler seem to of interest here.) Furthermore what are you trying to achieve using a Thread here? It's most likely that the CheckBoxes do not change between calling the threadPrice method and the execution of the runnable used with Platform.runLater.
– fabian
2 days ago












You get the NullPointerException at this line String strPrice = Integer.toString(price); ?
– Bo Halim
2 days ago




You get the NullPointerException at this line String strPrice = Integer.toString(price); ?
– Bo Halim
2 days ago












the issue is in salade.isSelected that returns null, i change the code and create a methode without thread like that: @FXML private void selectedSushi(ActionEvent event) { System.out.println("Check box"); if(salade.isSelected()) { System.out.println("salade selected"); price=price+Sushi.SALADE.getPrice(); } if(soupeMiso.isSelected()) { price=price+Sushi.SOUPE_MISOU.getPrice(); } if(soupe_miso_EBI.isSelected()) { price=price+Sushi.SOUPE_MISOU_EBI.getPrice(); } String prix= Integer.toString(price); textPrice.setText("Prix:"+prix);}
– Asmaa MOHAMEDI
2 days ago






the issue is in salade.isSelected that returns null, i change the code and create a methode without thread like that: @FXML private void selectedSushi(ActionEvent event) { System.out.println("Check box"); if(salade.isSelected()) { System.out.println("salade selected"); price=price+Sushi.SALADE.getPrice(); } if(soupeMiso.isSelected()) { price=price+Sushi.SOUPE_MISOU.getPrice(); } if(soupe_miso_EBI.isSelected()) { price=price+Sushi.SOUPE_MISOU_EBI.getPrice(); } String prix= Integer.toString(price); textPrice.setText("Prix:"+prix);}
– Asmaa MOHAMEDI
2 days ago














and it doesnt work, isSelected always returs null
– Asmaa MOHAMEDI
2 days ago




and it doesnt work, isSelected always returs null
– Asmaa MOHAMEDI
2 days ago












Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
– kleopatra
2 days ago




Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
– kleopatra
2 days ago

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Asmaa MOHAMEDI is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238277%2fjavafx-checkbox-thread%23new-answer', 'question_page');
}
);

Post as a guest





































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes








Asmaa MOHAMEDI is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















Asmaa MOHAMEDI is a new contributor. Be nice, and check out our Code of Conduct.













Asmaa MOHAMEDI is a new contributor. Be nice, and check out our Code of Conduct.












Asmaa MOHAMEDI is a new contributor. Be nice, and check out our Code of Conduct.















 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238277%2fjavafx-checkbox-thread%23new-answer', 'question_page');
}
);

Post as a guest




















































































Popular posts from this blog

The Sandy Post

Danny Elfman

Pages that link to "Head v. Amoskeag Manufacturing Co."