Build a JavaFX Scientific Calculator GUI Desktop App in Java

You are currently viewing Build a JavaFX Scientific Calculator GUI Desktop App in Java

In this article, You will understand the topic of “Build a JavaFX Scientific Calculator GUI Desktop App in Java”. Let’s start the article to learn about it below.

Build a JavaFX Scientific Calculator GUI Desktop App in Java

main.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.opeyemi.scientificcalculator;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

/**
 *
 * @author Idris Opeyemi
 */
public class ScientificCalculator extends Application {

    private static Stage primaryStage;

    public static Stage getPrimaryStage() {
        return primaryStage;
    }

    public static void setPrimaryStage(Stage primaryStage) {
        ScientificCalculator.primaryStage = primaryStage;
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        Font.loadFont(getClass().getResource("/font/digital-7.ttf").toExternalForm(), 10);

        Parent root = FXMLLoader.load(getClass().getResource("/fxml/ScientificCalculator.fxml"));
        System.out.println(root.toString());
        root.getStyleClass().add("anchorPane");
        Scene scene = new Scene(root);
        scene.setFill(Color.TRANSPARENT);
        primaryStage.setX(500.0);
        primaryStage.setY(80.0);
        primaryStage.setWidth(350);
        primaryStage.setHeight(600);
        primaryStage.setTitle("Calculator");
        primaryStage.setScene(scene);
        primaryStage.setResizable(false);
        primaryStage.initStyle(StageStyle.TRANSPARENT);
        primaryStage.show();
//        primaryStage.styl
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }

}

Scientific Calculator

This scientific calculator is a standard school calculator built in java FX and it almost a replica of the casio fx-82ms calculator with the some features and functionalities.

Scientific Calculator java

DOWNLOAD FULL SOURCE CODE

Final Words

I hope this article helps you to Build a JavaFX Scientific Calculator GUI Desktop App in Java. If you face any issues please let me know via the comment section. Share this article with other Java program developers via social networks. Thank You!

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply