// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package demo;

import javafx.application.Application;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.stage.Stage;

public class TrueJavaFXGUI extends Application {
    private Calculator data = new Calculator();
    @FXML
    private TextField number;
    @FXML
    private Label sqrt;
    @FXML
    private Label log;
    @FXML
    private Label exp;
    @Override
    public void start(Stage stg) throws Exception {
        stg.setTitle("True JavaFX GUI");
        Scene scn = new Scene((Parent) FXMLLoader.load(getClass().getResource("JavaFXGUI.fxml")));
        scn.getStylesheets().add(getClass().getResource("JavaFXGUI.css").toString());
        stg.setScene(scn);
        stg.show();
    }
    public void calcClick() {
        double x = Double.parseDouble(number.getText());
        data.setNumber(x);
        sqrt.setText(Double.toString(data.getSqrt()));
        log.setText(Double.toString(data.getLog()));
        exp.setText(Double.toString(data.getExp()));
    }
    public static void main(String[] args) {
        Application.launch(TrueJavaFXGUI.class, args);
    }
}
