Calculator - /* / Author: D.S. Malik / / GUI Calculator...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//************************************************************ // Author: D.S. Malik // // GUI Calculator Program // This program implements the arithmetic operations. //************************************************************ / import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; i public class Calculator extends JFrame implements ActionListener { private JTextField displayText = new JTextField(30); private JButton[] button = new JButton[16]; private String[] keys = {"7", "8", "9", "/", "4", "5", "6", "*", "1", "2", "3", "-", "0", "C", "=", "+"}; private String numStr1 = ""; private String numStr2 = ""; private char op; private boolean firstInput = true; public Calculator() { setTitle("My Calculator"); setSize(230, 200); Container pane = getContentPane(); pane.setLayout(null); displayText.setSize(200, 30); displayText.setLocation(10, 10); pane.add(displayText); int x, y; x = 10; y = 40; for (int ind = 0; ind < 16; ind++) { button[ind] = new JButton(keys[ind]);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/17/2011 for the course COMP 2301 taught by Professor Staff during the Spring '10 term at Kennesaw.

Page1 / 4

Calculator - /* / Author: D.S. Malik / / GUI Calculator...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online