Skip to content

Commit 9bb7679

Browse files
committed
Add Working Build
Now the application is working as expected. Getting this to export a Fat JAR File was so tedious.
1 parent 10a0b4d commit 9bb7679

File tree

9 files changed

+382
-61
lines changed

9 files changed

+382
-61
lines changed

.vscode/settings.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
{
2-
"java.configuration.updateBuildConfiguration": "automatic"
2+
"java.configuration.updateBuildConfiguration": "automatic",
3+
"java.project.exportJar.targetPath":"${workspaceFolder}/dist/${workspaceFolderBasename}.jar",
4+
"java.project.referencedLibraries": [
5+
"/usr/share/openjfx/lib/*.jar"
6+
]
37
}

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Simple Calculator
2+
A simple calculator with the most basic of features made with Java 11 and JavaFX.
3+
4+
## Development
5+
The build tool is Maven and to build the package along with the cross-platform JAR, do `mvn package`.
6+
7+
## How To Use
8+
Just download the JAR file on the releases page of the repository and run it on your own Java Virtual Machine. On Windows, if Java is installed properly, simply double clicking on the JAR file would run it.
9+
10+
## Features
11+
This calculator application has a simple working GUI.
12+
- Basic operations such as addition, subtraction, multiplication, and division.
13+
- Clear all button which resets the calculator's state.
14+
- Sign button which changes the sign of the number positive to negative and vice-versa.
15+
- Rate button which changes the number to a rate.
16+
17+
## Possible Improvements
18+
Ofcourse, this application isn't perfect. Currently there is no keyboard input handling and thus, the experience doesn't feel too smooth. That could be a future feature.
19+
20+
## Screenshot
21+
![Screenshot of the App](extra/Screenshot.png)

extra/Screenshot.png

290 KB
Loading

pom.xml

+100-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
54
<modelVersion>4.0.0</modelVersion>
65

76
<groupId>dev.sevora</groupId>
@@ -15,26 +14,121 @@
1514
<properties>
1615
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1716
<maven.compiler.source>11</maven.compiler.source>
17+
<maven.compiler.release>11</maven.compiler.release>
1818
<maven.compiler.target>11</maven.compiler.target>
19+
<javafx.version>11.0.2</javafx.version>
20+
<javafx.plugin.version>0.0.4</javafx.plugin.version>
21+
<main.class>dev.sevora.Main</main.class>
1922
</properties>
2023

2124
<dependencies>
25+
26+
<dependency>
27+
<groupId>org.openjfx</groupId>
28+
<artifactId>javafx-base</artifactId>
29+
<version>${javafx.version}</version>
30+
<classifier>win</classifier>
31+
</dependency>
32+
33+
<dependency>
34+
<groupId>org.openjfx</groupId>
35+
<artifactId>javafx-graphics</artifactId>
36+
<version>${javafx.version}</version>
37+
<classifier>win</classifier>
38+
</dependency>
39+
2240
<dependency>
2341
<groupId>org.openjfx</groupId>
2442
<artifactId>javafx-controls</artifactId>
25-
<version>17</version>
43+
<version>${javafx.version}</version>
44+
<classifier>win</classifier>
45+
</dependency>
46+
47+
<dependency>
48+
<groupId>org.openjfx</groupId>
49+
<artifactId>javafx-base</artifactId>
50+
<version>${javafx.version}</version>
51+
<classifier>mac</classifier>
52+
</dependency>
53+
54+
<dependency>
55+
<groupId>org.openjfx</groupId>
56+
<artifactId>javafx-graphics</artifactId>
57+
<version>${javafx.version}</version>
58+
<classifier>mac</classifier>
2659
</dependency>
27-
60+
61+
<dependency>
62+
<groupId>org.openjfx</groupId>
63+
<artifactId>javafx-controls</artifactId>
64+
<version>${javafx.version}</version>
65+
<classifier>mac</classifier>
66+
</dependency>
67+
68+
<dependency>
69+
<groupId>org.openjfx</groupId>
70+
<artifactId>javafx-base</artifactId>
71+
<version>${javafx.version}</version>
72+
<classifier>linux</classifier>
73+
</dependency>
74+
75+
<dependency>
76+
<groupId>org.openjfx</groupId>
77+
<artifactId>javafx-graphics</artifactId>
78+
<version>${javafx.version}</version>
79+
<classifier>linux</classifier>
80+
</dependency>
81+
82+
<dependency>
83+
<groupId>org.openjfx</groupId>
84+
<artifactId>javafx-controls</artifactId>
85+
<version>${javafx.version}</version>
86+
<classifier>linux</classifier>
87+
</dependency>
88+
2889
<dependency>
2990
<groupId>junit</groupId>
3091
<artifactId>junit</artifactId>
3192
<version>4.11</version>
3293
<scope>test</scope>
3394
</dependency>
95+
3496
</dependencies>
3597

3698
<build>
37-
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
99+
<plugins>
100+
<plugin>
101+
<groupId>org.openjfx</groupId>
102+
<artifactId>javafx-maven-plugin</artifactId>
103+
<version>${javafx.plugin.version}</version>
104+
<configuration>
105+
<mainClass>${main.class}</mainClass>
106+
</configuration>
107+
</plugin>
108+
109+
<plugin>
110+
<artifactId>maven-shade-plugin</artifactId>
111+
<version>3.2.4</version>
112+
<executions>
113+
<execution>
114+
<phase>package</phase>
115+
<goals>
116+
<goal>shade</goal>
117+
</goals>
118+
<configuration>
119+
<transformers>
120+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
121+
<Main-Class>${main.class}</Main-Class>
122+
</transformer>
123+
</transformers>
124+
</configuration>
125+
</execution>
126+
</executions>
127+
</plugin>
128+
</plugins>
129+
<pluginManagement>
130+
<!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
131+
38132
<plugins>
39133
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
40134
<plugin>
@@ -78,4 +172,4 @@
78172
</plugins>
79173
</pluginManagement>
80174
</build>
81-
</project>
175+
</project>

src/main/java/dev/sevora/App.java

+18-6
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,34 @@
77
import javafx.stage.Stage;
88

99
/**
10-
* Hello world!
11-
*
10+
* App --- calculator program with GUI that uses Java 11 and JavaFX .
11+
* @author Ralph Louis Gopez
1212
*/
1313
public class App extends Application
1414
{
15-
private Calculator calculator = new Calculator();
16-
private Layout layout = new Layout(400, 600);
17-
18-
boolean hasTyped = false;
15+
private Calculator calculator = new Calculator(); // This is what is used for the functionality in terms of logic of the app.
16+
private Layout layout = new Layout(400, 600); // JavaFX Objects
1917

18+
/**
19+
* Launches the JavaFX application.
20+
* @param args
21+
*/
2022
public static void main( String[] args )
2123
{
2224
launch(args);
2325
}
2426

27+
/**
28+
* Starts the application.
29+
* @param primaryStage A JavaFX Stage Instance.
30+
*/
2531
@Override
2632
public void start(Stage primaryStage) {
33+
// The GUI and the Logic is separated by design.
2734
Layout layout = this.layout;
2835
Button[] buttons = this.layout.getButtons();
2936

37+
// This binds the event handler on all the buttons
3038
for (Button button : buttons) {
3139
if (button != null) {
3240
button.setOnAction(event -> buttonHandler(event));
@@ -39,6 +47,10 @@ public void start(Stage primaryStage) {
3947
primaryStage.show();
4048
}
4149

50+
/**
51+
* Used as the callback for a button click.
52+
* @param event This is the event passed from the button.
53+
*/
4254
public void buttonHandler(ActionEvent event) {
4355
Button button = (Button) event.getSource();
4456
Calculator calculator = this.calculator;

0 commit comments

Comments
 (0)