package calculator; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class View extends JFrame { public View(Controller controller) { super("Calculator"); final String[] LABELS = { "7", "8", "9", "+", "4", "5", "6", "-", "1", "2", "3", "*", "0", "?", "=", "/" }; JPanel buttons = new JPanel(); final int ROWS = 4; final int COLUMNS = 4; final int GAP = 10; GridLayout buttonLayout = new GridLayout(ROWS, COLUMNS, GAP, GAP); buttons.setLayout(buttonLayout); for (String label : LABELS) { JButton button = new JButton(label); button.setActionCommand(label); button.addActionListener(controller); buttons.add(button); } this.add(buttons); } }