Calculator.java - import import import import import import...

This preview shows page 1 - 2 out of 2 pages.

import java.awt.BorderLayout; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextField; public class Calculator extends JFrame { private final int APPLICATION_WIDTH=200; private final int APPLICATION_HEIGHT=250; public static void main(String[] args) { new Calculator(); } //GUIProgram constructor that sets the title, size //Creates an JPanel object add inputPanel and button panel //to panel public Calculator() { setTitle("Calculator"); setSize(APPLICATION_WIDTH, APPLICATION_HEIGHT);; setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Create an instance of JPanel JPanel mainpanel=new JPanel(); mainpanel.setLayout(new BorderLayout()); mainpanel.add(createInputPanel(), BorderLayout.NORTH); mainpanel.add(createButtonPanel(), BorderLayout.CENTER); add(mainpanel); setVisible(true); pack(); } /**The method createButtonPanel creats the button panel*/ private JPanel createButtonPanel() { //Create an instance of JPanel JPanel buttonPanel=new JPanel(); //Create layout of GridLayout of size ,4x4 buttonPanel.setLayout(new GridLayout(4, 4,5,5));

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture