I am having trouble registering an Event Handler that is supposed to calculate the total of the user's input of a meal cost, their desired tip%, and the sales tax. I keep getting an error message that says "missing method body, or declare abstract". There appears to be no syntax errors so I'm not quite sure what the problem is.

Im honestly stuck at this point and havent a clue what the problem is.

public class TipTaxTotal extends Application
    private TextField mealCostTextField;
    private TextField tipPercentageTextField;
    private TextField salesTaxTextField;
    private Label totalLabel;

    public static void main (String[] args)


    public void start (Stage primaryStage)
    //Meal cost, Tip percentage, and Sales tax labels & TextFields

        Label mealCostLabel = new Label ("Enter the cost of your meal");

        mealCostTextField = new TextField ();

        Label tipPercentageLabel = new Label ("Enter the desired tip percentage");

                tipPercentageTextField = new TextField ();

        Label salesTaxLabel = new Label ("Enter the sales tax percentage");

                salesTaxTextField = new TextField ();

        //This button will perform the calculation
        Button calcButton = new Button("Calculate");

        //Register the event handler
        calcButton.setOnAction(new CalcButtonHandler());

        //This label will display the total
        totalLabel = new Label ();

        //Put all the Labels and Text Fields in the Hbox spaced by 10 px
        HBox hbox = new HBox(10, mealCostLabel, mealCostTextField,
                tipPercentageLabel, tipPercentageTextField, salesTaxLabel,

        //Put Hbox, CalcButton, and total Label in the Vbox
        VBox vbox = new VBox(10, hbox, calcButton, totalLabel);

        //align vbox to the center of the stage

        //set vbox padding to 10 px
        vbox.setPadding(new Insets(10));

        //create a scene
        Scene scene = new Scene(vbox);

        //add the scene to the stage

        //give the stage a title
        primaryStage.setTitle("Tip% and Sales Tax Calculator");


    //This is where my trouble is
    //event handler
    class CalcButtonHandler implements EventHandler<ActionEvent>

        public void handle(ActionEvent event);
            //get the meal cost, tip percentage, and sales tax

            double MealCost =

            double TipPercentage =

            double SalesTax =
            double totalTaxes = SalesTax + TipPercentage;
            double total = MealCost * totalTaxes;

            //display total

            totalLabel.setText(String.format("Total: $%,.2f ", total));

The calcButton is supposed to get the total cost of the users's meal, user's desired tip, and the user's sales tax.

1 Answers

András El Koulali On Best Solutions

You simply don't need @Override when implementing interfaces, because interfaces aren't equal with abstract classes. You can't override an interface method, because it's not defined and it's not marked abstract.