Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

169
Views
How To Write To Txt File Using If Else Statement Within a Button

Fixed the problem, thanks for all the help c:

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

To track iceCream selected, simply add new field iceCream. And assign a value to it once it's selected. Do the same with you toppingsCost:

public class FXMLDocumentController implements Initializable {

    private String iceCream;
    private double toppingsCost;

....
    private void handleButtonSaving(ActionEvent event) {
        if(vanilla.isSelected()) {
        iceCream = "Vanilla";
        System.out.println(iceCream);
        }
        if(chocolate.isSelected()) {
        iceCream = "Chocolate";
        System.out.println(iceCream);
        }
        ...

    private void handleButtonCalculateCost(ActionEvent event) {
        double myTotal = 0.0;

        myTotal += retrieveIceCreamCost();
        toppingsCost = retrieveToppingsCost();
        myTotal +=  toppingsCost;
        ...
over 4 years ago · Santiago Trujillo Report

0

Consider how RadioButtons are grouped by a ToggleGroup. In code:

final ToggleGroup icecream = new ToggleGroup();

RadioButton rb1 = new RadioButton("Vanilla");
rb1.setToggleGroup(icecream);
rb1.setSelected(true);

RadioButton rb2 = new RadioButton("Chocolate");
rb2.setToggleGroup(icecream);

RadioButton rb3 = new RadioButton("Strawberry");
rb3.setToggleGroup(icecream);

You can handle all selection by the ToggleGroup component.

RadioButton selected = (RadioButton) icecream.getSelectedToggle();

ObservableList<Toggle> radioButtons = icecream.getToggles();

Writing the selected radio button's label (say "Vanilla") and later reading "Vanilla" and looping through all radioButtons to select the matching one is not too circumstantial.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!