CalcFrame.java - import import import import javax.swing...

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

import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class CalcFrame extends JFrame { JTextArea display= new JTextArea(); JPanel buttonPanel = new JPanel(new GridLayout(5,3)); JButton button0 = new JButton("0"); JButton button1 = new JButton("1"); JButton button2 = new JButton("2"); JButton button3 = new JButton("3"); JButton button4 = new JButton("4"); JButton button5 = new JButton("5"); JButton button6 = new JButton("6"); JButton button7 = new JButton("7"); JButton button8 = new JButton("8"); JButton button9 = new JButton("9"); JButton buttonSum = new JButton("+"); JButton buttonBack = new JButton("C"); JButton buttonDivide = new JButton("/"); JButton buttonSub = new JButton("-"); JButton buttonMul = new JButton("*"); JButton buttonStart = new JButton("="); int firstValue = 0; String operation = "+"; CalcFrame() { setBounds(300, 300, 300, 300); button0.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { display.setText(display.getText() + "0"); } }); button1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { display.setText(display.getText()+"1");

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture