If anyone is interested in Java 8, you can do the "handleOptions" method like this (the output will be something like "Bacon, Tuna, Beef" and the call is just handleOptions(box1, box2, box3) or whatever checkboxes you have): private void handleOptions(CheckBox... boxes) { System.out.println(String.join( ", ", Arrays.stream(boxes).filter(CheckBox::isSelected).map(CheckBox::getText).collect(Collectors.toList()) )); }
thanks a lot for your tutorial. up from line47 you don't have to write bacon/tuna... its more useful to work with gettext, in case, that the checkbox-text changes later (for not adapting manually in the code ;)). igual! thank you. :)
Make a checkbox array and use this code for printing out the order: public void printOrder(){ String message = "Order: "; for (CheckBox checkBox : checkBoxes){ message += checkBox.isSelected() ? checkBox.getText() + " " : ""; } System.out.println(message); } It's much more flexible.
What if you have many checkboxes, it seems strange to use an if + else statement for all of them. Is it possible to process them through an array (+ for loop) or something similar? Sorry I'm a newb to java
hi, how can we select only one check box and not more than that. Basically i want to create checkbox for gender. So only one gender can be selected. Hope to hear any answer soon.
your videos are just awesome but just it would have been better if you would have zoomed in the code while typing as it would have been more readable. Currently its too small to read properly :(
Sir What should i learn after learning this whole tutorials of java fx...plesae sir guide me..i want to learn the programming...i am a software Engineering Student....
i am sure by now your already doing java programming, after this he will introduce scene builder, which is used to build these layouts faster and better.
it has been 7 years but i need to know. For example, we want to save our customers order patterns. and lets say we have 7 checkboxes, they always check 4 of them. how can we save this. even after they closed the app. i dont know how "keep me logged in" works but i guess it saves our history and uses them. So, I just want to know how to save lets say previous checked boxes. Can someone help me ? @thenewboston ?
the best teacher I've come across
5:39 - *thinking intensifies.*
If anyone is interested in Java 8, you can do the "handleOptions" method like this (the output will be something like "Bacon, Tuna, Beef" and the call is just handleOptions(box1, box2, box3) or whatever checkboxes you have):
private void handleOptions(CheckBox... boxes) {
System.out.println(String.join(
", ",
Arrays.stream(boxes).filter(CheckBox::isSelected).map(CheckBox::getText).collect(Collectors.toList())
));
}
i love streams :D
i know it comes late, but your tutorials are awesome :D
Isn't late.
Insets(20, 20, 20, 20) can be simplified to Insets(20)
when you want to combine two Strings use string1.concat(string2)
Where Exactly Did He Need To Do This In That Tutorial ?
Hoagies, grinders, po'boys, spuckies, or even "wedges". I think that covers all the "Subs" names. Now please update your video to include these :D
such an useful course it was. Thank you for making it
thanks a lot for your tutorial. up from line47 you don't have to write bacon/tuna... its more useful to work with gettext, in case, that the checkbox-text changes later (for not adapting manually in the code ;)). igual! thank you. :)
Make a checkbox array and use this code for printing out the order:
public void printOrder(){
String message = "Order:
";
for (CheckBox checkBox : checkBoxes){
message += checkBox.isSelected() ? checkBox.getText() + "
" : "";
}
System.out.println(message);
}
It's much more flexible.
Good example
Cuts down on repetition and makes it easy adding / removing checkboxes
Thanks. Best solution for my issue.
Thank you again! Great job!
Welcome to Bucky's meat subs ... do you want some meat with that?
i am so much thx for making this. thx
They are called a 'hero' here in NY.
What if you have many checkboxes, it seems strange to use an if + else statement for all of them. Is it possible to process them through an array (+ for loop) or something similar? Sorry I'm a newb to java
Yes you can use a forloop to loop through all of the checkboxes and see if. They are selected
thank you
hi, how can we select only one check box and not more than that. Basically i want to create checkbox for gender. So only one gender can be selected. Hope to hear any answer soon.
you can type "sout" and press enter instead of type system.out.println()
Some people call them heroes
i call my home-made subs hogies
Real Time Billing
public void start(Stage primaryStage) throws Exception{
CheckBox idli = new CheckBox("Idli");
CheckBox vada = new CheckBox("Vadai");
CheckBox dosa = new CheckBox("Dosa");
total = new TextField("0");
idli.setOnAction(e->
{
Update(idli,8);
}
);
vada.setOnAction(e->
{
Update(vada,6);
}
);
dosa.setOnAction(e->
{
Update(dosa,45);
}
);
VBox vb = new VBox(40);
vb.getChildren().addAll(dosa,idli,vada,total);
vb.setAlignment(Pos.CENTER);
Scene scene = new Scene(vb,500,500);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
private void Update(CheckBox check,int rate)
{
if(check.isSelected())
total.setText( String.valueOf(Integer.parseInt(total.getText()) + rate));
else
total.setText( String.valueOf(Integer.parseInt(total.getText()) - rate));
}
your videos are just awesome but just it would have been better if you would have zoomed in the code while typing as it would have been more readable. Currently its too small to read properly :(
hi, how to select just one checkbox, (to choose just one option)?
you need to use radio button instead
Hoagies for life man!
We can improve this by
private void handleOptions(CheckBox... boxes) {
System.out.println("Users order: ");
for(CheckBox box : boxes ) {
if(box.isSelected()
System.out.println(box.getText());
}
}
Sir What should i learn after learning this whole tutorials of java fx...plesae sir guide me..i want to learn the programming...i am a software Engineering Student....
i am sure by now your already doing java programming, after this he will introduce scene builder, which is used to build these layouts faster and better.
Thank u #Mayobyo Hassan....
Some people call subs 'Heros'
I am here 2020
How i disable for the user dont check/uncheck? i want to use this as a flag status...
Hey - not that you could tell, but all i eat is meat and dairy in a Sub, only thing close to salad/fruit/vegetable is Tomato Sauce... LOL
what is vBox?
I want to order bacontuna.
Stromboli
//Handle checkbox options
private void handleOptions(JFXCheckBox... args){
StringBuilder elementsSelected = new StringBuilder();
for (JFXCheckBox arg : args) {
if (arg.isSelected()) {
elementsSelected.append(arg.getText()).append("
");
}
}
AlertBox.display("Alert Box", "Elements selected:
" + elementsSelected);
}
P
A sub is a Hero in New York City
it has been 7 years but i need to know. For example, we want to save our customers order patterns. and lets say we have 7 checkboxes, they always check 4 of them. how can we save this. even after they closed the app. i dont know how "keep me logged in" works but i guess it saves our history and uses them. So, I just want to know how to save lets say previous checked boxes. Can someone help me ? @thenewboston ?