Implement initial UI with textbox

Co-Authored-By: td1223
This commit is contained in:
Gleb Koval 2024-11-05 17:22:39 +00:00
parent b9dbfb86ad
commit 45a06ab15e
Signed by: cyclane
GPG Key ID: 15E168A8B332382C
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,12 @@
package ic.doc;
public class RpnCalculator {
private static final int DEFAULT_WIDTH = 400;
private static final int DEFAULT_HEIGHT = 400;
public static void main(String[] args) {
RpnCalculatorGui calculatorGui = RpnCalculatorGui.withDimensions(DEFAULT_WIDTH, DEFAULT_HEIGHT);
calculatorGui.display();
}
}

View File

@ -0,0 +1,34 @@
package ic.doc;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class RpnCalculatorGui {
private final int defaultWidth;
private final int defaultHeight;
private static final int RESULT_FIELD_WIDTH = 10;
public static RpnCalculatorGui withDimensions(int defaultWidth, int defaultHeight) {
return new RpnCalculatorGui(defaultWidth, defaultHeight);
}
private RpnCalculatorGui(int defaultWidth, int defaultHeight) {
this.defaultWidth = defaultWidth;
this.defaultHeight = defaultHeight;
}
public void display() {
JFrame frame = new JFrame("RPN Calculator");
frame.setSize(defaultWidth, defaultHeight);
JPanel panel = new JPanel();
JTextField resultField = new JTextField(RESULT_FIELD_WIDTH);
panel.add(resultField);
frame.add(panel);
frame.setVisible(true);
}
}