fixed build process and added project configuration files from idea
Some checks failed
Build the Jar / build (push) Failing after 11s

This commit is contained in:
2025-12-14 08:22:47 -06:00
parent d472f6ac5e
commit cfa433fd90
26 changed files with 285 additions and 119 deletions

View File

@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="C:/Users/S700880/eclipse-workspace/Calc/src/main/java/flatlaf-3.7.jar">
<classpathentry kind="lib" path="C:/Users/S700880/eclipse-workspace/Calc/src/main/java/flatlaf-3.7-javadoc.jar">
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -12,8 +12,43 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Set up JDK 20 - name: Set up JDK 20
uses: actions/setup-java@v5 uses: actions/setup-java@v5
with: with:
java-version: '20' java-version: '20'
distribution: 'temurin' distribution: 'temurin'
- name: Create output directories
run: |
mkdir -p out/production/Calc
mkdir -p dist
- name: Compile Java files
run: |
javac -encoding UTF-8 -cp "lib/flatlaf-3.7.jar" -d out/production/Calc \
$(find src/main/java -name "*.java")
- name: Copy resources
run: |
if [ -d "src/main/resources" ]; then
cp -r src/main/resources/* out/production/Calc/ 2>/dev/null || true
fi
- name: Create manifest
run: |
echo "Manifest-Version: 1.0" > manifest.txt
echo "Main-Class: dev.sillyangel.calc.Calculator" >> manifest.txt
echo "Class-Path: lib/flatlaf-3.7.jar" >> manifest.txt
- name: Create JAR
run: |
cd out/production/Calc
jar cfm ../../../dist/CalcShortforCalculator.jar ../../../manifest.txt .
cd ../../..
- name: Upload JAR artifact
uses: actions/upload-artifact@v4
with:
name: CalcShortforCalculator
path: dist/CalcShortforCalculator.jar

10
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,10 @@
# Default ignored files
/shelf/
/workspace.xml
# Ignored default folder with query files
/queries/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

6
.idea/copilot.data.migration.agent.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AgentMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

6
.idea/copilot.data.migration.ask.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AskMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

6
.idea/copilot.data.migration.edit.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EditMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

7
.idea/discord.xml generated Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="APPLICATION" />
<option name="description" value="" />
</component>
</project>

10
.idea/libraries/lib.xml generated Normal file
View File

@@ -0,0 +1,10 @@
<component name="libraryTable">
<library name="lib">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/flatlaf-3.7.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/flatlaf-3.7-javadoc.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

6
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" project-jdk-name="temurin-20" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Calc.iml" filepath="$PROJECT_DIR$/Calc.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CalculatorButBetter</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1763046761202</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>

View File

@@ -1,2 +0,0 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@@ -1,12 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=20
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=20
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=20

15
Calc.iml Normal file
View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/.gitea" />
<excludeFolder url="file://$MODULE_DIR$/.idea" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="lib" level="project" />
</component>
</module>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@@ -134,22 +134,26 @@ public class Calculator extends JFrame implements KeyListener {
} }
}); });
modeselect.setEditable(false); modeselect.setEditable(false);
modeselect.setFocusable(false);
JButton btnNewButton_1 = new JButton("New button"); JButton btnNewButton_1 = new JButton("New button");
btnNewButton_1.setFocusable(false);
JLabel lblNewLabel = new JLabel("New label"); JLabel lblNewLabel = new JLabel("New label");
lblNewLabel.setFocusable(false);
panel.add(modeselect); panel.add(modeselect);
panel.add(lblNewLabel); panel.add(lblNewLabel);
panel.add(btnNewButton_1); panel.add(btnNewButton_1);
JButton empty_4 = new JButton(""); JButton btnPercent = new JButton("%");
JButton empty_1 = new JButton(""); JButton btnClearEntry = new JButton("CE");
JButton empty_2 = new JButton(""); JButton btnReciprocal = new JButton("1/x");
JButton empty = new JButton(""); JButton btnSquare = new JButton("");
JButton empty_3 = new JButton(""); JButton btnSquareRoot = new JButton("√x");
JButton btnErase = new JButton("DEL"); // Use FlatLaf Tree.icon.collapsed as backspace-like icon (or just use text)
JButton btnBackspace = new JButton("");
JButton btnClear = new JButton("C"); JButton btnClear = new JButton("C");
JButton btnPlusMin = new JButton("+/-"); JButton btnPlusMin = new JButton("+/-");
JButton btnDot = new JButton("."); JButton btnDot = new JButton(".");
@@ -186,15 +190,21 @@ public class Calculator extends JFrame implements KeyListener {
} }
}); });
btnErase.addActionListener(new ActionListener() { btnBackspace.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
clear(); backspace();
}
});
btnClearEntry.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
clearEntry();
} }
}); });
btnClear.addActionListener(new ActionListener() { btnClear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
clear(); clearAll();
} }
}); });
@@ -295,10 +305,35 @@ public class Calculator extends JFrame implements KeyListener {
} }
}); });
btnPercent.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setOperator("%");
}
});
btnReciprocal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
reciprocal();
}
});
btnSquare.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
square();
}
});
btnSquareRoot.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
squareRoot();
}
});
btnErase.setFont(new Font("Segoe UI", Font.PLAIN, 29));
btnBackspace.setFont(new Font("Segoe UI", Font.PLAIN, 29));
btnClear.setFont(new Font("Segoe UI", Font.PLAIN, 29)); btnClear.setFont(new Font("Segoe UI", Font.PLAIN, 29));
btnClearEntry.setFont(new Font("Segoe UI", Font.PLAIN, 29));
btnPlusMin.setFont(new Font("Segoe UI", Font.PLAIN, 29)); btnPlusMin.setFont(new Font("Segoe UI", Font.PLAIN, 29));
btnEq.setFont(new Font("Segoe UI", Font.PLAIN, 29)); btnEq.setFont(new Font("Segoe UI", Font.PLAIN, 29));
btnDot.setFont(new Font("Segoe UI", Font.PLAIN, 29)); btnDot.setFont(new Font("Segoe UI", Font.PLAIN, 29));
@@ -316,20 +351,44 @@ public class Calculator extends JFrame implements KeyListener {
btnMin.setFont(new Font("Segoe UI", Font.PLAIN, 29)); btnMin.setFont(new Font("Segoe UI", Font.PLAIN, 29));
btnDiv.setFont(new Font("Segoe UI", Font.PLAIN, 29)); btnDiv.setFont(new Font("Segoe UI", Font.PLAIN, 29));
btnPlus.setFont(new Font("Segoe UI", Font.PLAIN, 29)); btnPlus.setFont(new Font("Segoe UI", Font.PLAIN, 29));
btnPercent.setFont(new Font("Segoe UI", Font.PLAIN, 29));
btnReciprocal.setFont(new Font("Segoe UI", Font.PLAIN, 29));
btnSquare.setFont(new Font("Segoe UI", Font.PLAIN, 29));
btnSquareRoot.setFont(new Font("Segoe UI", Font.PLAIN, 29));
empty.setEnabled(false); // Make all buttons non-focusable so keyboard input always goes to the frame
empty_1.setEnabled(false); btnBackspace.setFocusable(false);
empty_2.setEnabled(false); btnClear.setFocusable(false);
empty_3.setEnabled(false); btnClearEntry.setFocusable(false);
empty_4.setEnabled(false); btnPlusMin.setFocusable(false);
btnEq.setFocusable(false);
btnDot.setFocusable(false);
btn0.setFocusable(false);
btn1.setFocusable(false);
btn2.setFocusable(false);
btn3.setFocusable(false);
btn4.setFocusable(false);
btn5.setFocusable(false);
btn6.setFocusable(false);
btn7.setFocusable(false);
btn8.setFocusable(false);
btn9.setFocusable(false);
btnMul.setFocusable(false);
btnMin.setFocusable(false);
btnDiv.setFocusable(false);
btnPlus.setFocusable(false);
btnPercent.setFocusable(false);
btnReciprocal.setFocusable(false);
btnSquare.setFocusable(false);
btnSquareRoot.setFocusable(false);
buttonPanel.add(empty); buttonPanel.add(btnPercent);
buttonPanel.add(empty_3); buttonPanel.add(btnClearEntry);
buttonPanel.add(btnClear); buttonPanel.add(btnClear);
buttonPanel.add(btnErase); buttonPanel.add(btnBackspace);
buttonPanel.add(empty_4); buttonPanel.add(btnReciprocal);
buttonPanel.add(empty_1); buttonPanel.add(btnSquare);
buttonPanel.add(empty_2); buttonPanel.add(btnSquareRoot);
buttonPanel.add(btnDiv); buttonPanel.add(btnDiv);
buttonPanel.add(btn7); buttonPanel.add(btn7);
buttonPanel.add(btn8); buttonPanel.add(btn8);
@@ -362,7 +421,7 @@ public class Calculator extends JFrame implements KeyListener {
} }
} }
void clear() { void backspace() {
String tmp = display.getText(); String tmp = display.getText();
if (tmp.length()>1) // if there is more than 1 character if (tmp.length()>1) // if there is more than 1 character
display.setText( tmp.substring(0, tmp.length()-1) ); display.setText( tmp.substring(0, tmp.length()-1) );
@@ -370,6 +429,51 @@ public class Calculator extends JFrame implements KeyListener {
display.setText(""); display.setText("");
} }
void clearEntry() {
// Clear only the current display (entry)
display.setText("");
}
void clearAll() {
// Clear everything including operands and operator
display.setText("");
operand1 = "";
operand2 = "";
operator = "";
resultVisible = false;
}
void reciprocal() {
String tmp = display.getText();
if (tmp == null || tmp.isEmpty()) return;
double value = Double.parseDouble(tmp);
if (value != 0) {
result = 1.0 / value;
display.setText("" + result);
resultVisible = true;
}
}
void square() {
String tmp = display.getText();
if (tmp == null || tmp.isEmpty()) return;
double value = Double.parseDouble(tmp);
result = value * value;
display.setText("" + result);
resultVisible = true;
}
void squareRoot() {
String tmp = display.getText();
if (tmp == null || tmp.isEmpty()) return;
double value = Double.parseDouble(tmp);
if (value >= 0) {
result = Math.sqrt(value);
display.setText("" + result);
resultVisible = true;
}
}
void processDigit(String actionCommand) { void processDigit(String actionCommand) {
if (resultVisible == true) { if (resultVisible == true) {
display.setText(""); display.setText("");
@@ -418,6 +522,8 @@ public class Calculator extends JFrame implements KeyListener {
result = op1*op2; result = op1*op2;
} else if (operator == "/") { } else if (operator == "/") {
result = op1/op2; result = op1/op2;
} else if (operator == "%") {
result = op1 % op2;
} else { } else {
result = op2; result = op2;
System.out.println("Op: " + op1); System.out.println("Op: " + op1);
@@ -445,7 +551,7 @@ public class Calculator extends JFrame implements KeyListener {
if (KeyEvent.getKeyText(keyCode) == "Enter") { if (KeyEvent.getKeyText(keyCode) == "Enter") {
math(); math();
} else if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) { } else if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
clear(); backspace();
} }
} }

Binary file not shown.