parent
b9dbfb86ad
commit
45a06ab15e
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue