help me
@pantherjerung (3)
Malaysia
October 8, 2006 12:12pm CST
import java.io.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class CalculatorFrame2 extends JFrame
{
private Container contentPane;
//The componenets used in the calculator
private JTextField display;
private JButton addition;
private JButton subtract;
private JButton multiply;
private JButton divide;
private JButton mod;
private JButton enter;
private JButton [] digits;
//End of components
//Integer representations for the arithmetic operations needed
private final static int ADD = 1;
private final static int SUB = 2;
private final static int MUL = 3;
private final static int DIV = 4;
private final static int MOD = 5;
//ENd of arithmethic operations
//Integer holding the operator that the user requested
private int op;
//Boolean variable to help perform the calculations
private boolean firstFilled;
private boolean clearScreen;
//Constructor for the class
public CalculatorFrame()
{
contentPane=new Container();
this.setSize(400,300); //sets the size of the frame
this.setTitle("MIS 222 Calculator"); //sets the title of the frame
//allows the "X" box in the upper right hand corner to close the entire application
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane=this.getContentPane(); //gets the content pane
//Methods
addDisplay();
addDigits();
addDigitActionListeners();
addOperation();
}
private void addDisplay()
{
JLabel displayLab = new JLabel("Answer");
JPanel north = new JPanel();
north.add(displayLab);
contentPane.add(north, "north");
//diplay was already declared above the constructor
display = new JTextField(25);
//adding the components to the panel
north.add(displayLab);
north.add(display);
//adding the panel to frame's content pane
contentPane.add(north, "north");
}
//Declaring the global digits array
private void addDigits()
{
//Add 1 large panel to hold the 3 inner panels
JPanel digPanel = new JPanel();
//Set the panel's preferred size so that it will keep everything in line
digPanel.setPreferredSize(new Dimension(200, 275));
//Initialize the top 3 digits' JPanel and set its preferrd size
JPanel topDigits = new JPanel();
topDigits.setPreferredSize(new Dimension(200,60));
//Initialize the middle 2 digits' JPanel and set its preferred size
JPanel midDigits = new JPanel();
midDigits.setPreferredSize(new Dimension(200,60));
//Initialize the bottom digits' JPanel and set its preferred size
JPanel botDigits = new JPanel();
botDigits.setPreferredSize(new Dimension(200, 75));
//Initialize the JButton array
digits = new JButton[11];
//Initialize each of the top Panel's digit buttons, and add it to the top panel
for(int i=1; i
1 response
@pantherjerung (3)
• Malaysia
9 Oct 06
my coding have 6 error
i hope you can help me 2 solve this problem
plz help me