java – JavaFX Basic 4-Function Calculator

I would appreciate your comments on any improvement I can make in this 4-function calculator that I wrote in Java with JavaFX. I used a Scene Builder for the design, see the Java and FXML code below. Thank you!

Main.java

packet calculator;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.util.logging.Level;
import java.util.logging.Logger;

Main public class extends the application {
Private static final logger LOGGER = Logger.getLogger (Logger.GLOBAL_LOGGER_NAME);

@Cancel
public void start (Stage primaryStage) launches Exception {
Main root = FXMLLoader.load (getClass (). GetResource ("calculator.fxml"));
primaryStage.setTitle ("Calculator");
primaryStage.setScene (new scene (root));
primaryStage.show ();
}


Empty main static public (String[] args) {
LOGGER.setLevel (Level.INFO);
launch (args);
}
}

Controller.java

packet calculator;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.util.logging.Level;
import java.util.logging.Logger;

Public class controller {
Private static final logger LOGGER = Logger.getLogger (Logger.GLOBAL_LOGGER_NAME);
ScriptEngine private engine;

@FXML
text field private text field;

@FXML
initialize private vacuum () {
engine = new ScriptEngineManager (). getEngineByName ("JavaScript");
LOGGER.info ("Engine created, ready for the entrance!");
}

@FXML
private null calculationsAnswer () {
if (text_field.getLength () == 0) {
Clear();
}

try {
text_field.setText (engine.eval (text_field.getText ()). toString ());
} catch (ScriptException scriptException) {
/ *
* An exception will be thrown if an invalid entry is entered.
* An example is * 2 since it would not be a valid operation.
* Our answer is to gracefully delete the TextField output.
* /
LOGGER.log (Level.SEVERE, "Invalid entry  n" + scriptException.getMessage ());
Clear();
}
}

@FXML
private void addToTextField (ActionEvent event) {
String buttonText = getButtonText (event);
if (textFieldIsEmpty ()) {
text_field.setText (buttonText);
} else {
text_field.appendText (buttonText);
}
}

@FXML
empty private clear () {
text_field.setText ("0");
}

/ **
* Check if TextField contains a single zero, which means it is "empty".
*
* @he came back true if it is empty, otherwise it returns false.
* /
Private Boolean textFieldIsEmpty () {
returns text_field.getLength () == 1 && text_field.getText (). equals ("0");
}

Private String getButtonText (ActionEvent event) {
return ((Button) event.getSource ()). getText ();
}
}

calulator.fxml