Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ahatem committed Sep 13, 2022
1 parent 31da60a commit b157bbc
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

Simple swing calculator with simple math expression parser

![Screenshot](/images/1.png?raw=true)
![Screenshot Dark](/images/1.png?raw=true)
![Screenshot Light](/images/2.png?raw=true)

---

Expand Down
Binary file modified images/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions src/main/java/main/Main.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main;

import com.formdev.flatlaf.intellijthemes.FlatHiberbeeDarkIJTheme;
import com.formdev.flatlaf.intellijthemes.FlatCyanLightIJTheme;
import main.ui.CalculatorFrame;

import javax.swing.*;
Expand All @@ -9,8 +9,10 @@ public class Main {
public static void main(String[] args) {
UIManager.put("Button.arc", 0);
UIManager.put("Button.innerFocusWidth", 0);
FlatHiberbeeDarkIJTheme.setup();
UIManager.put("Component.focusWidth", 0);

// FlatHiberbeeDarkIJTheme.setup(); // Dark Theme
FlatCyanLightIJTheme.setup(); // Light Theme
SwingUtilities.invokeLater(CalculatorFrame::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private String convertToPostfixExpression(String expression) {
// empty spaces in " %c " are important cuz we use it to split the expression into tokens (in buildExpression)
while (stack.peek() != '(')
postfixExpression.append(" %c ".formatted(stack.pop()));
stack.pop();
stack.pop(); // to pop '('
} else {
while (!stack.isEmpty() && (priority(character) <= priority(stack.peek())))
postfixExpression.append(" %c ".formatted(stack.pop()));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/main/ui/CalculatorFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class CalculatorFrame extends JFrame {

public CalculatorFrame() {
super("Simple Calculator");
setPreferredSize(new Dimension(290, 400));
setPreferredSize(new Dimension(330, 430));
setMinimumSize(new Dimension(290, 400));
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

Expand Down

0 comments on commit b157bbc

Please sign in to comment.