[求助]关于用Java实现ATM机的挠头难题,大家会么?
Java论坛没人,只好老这里了大家好!最近我在编个ATM机GUI程序,用swing做,可是现在遇到4个错误了,但我一直不知道怎么解决。
我的主程序AtmGUI程序如下, 现在总是提示红色字的地方有问题,“cannot resolve symbol : constructor KeyPad (AtmGUI)”和“cannot resolve symbol : constructor KeyPad (AtmGUI)”
万能的搂住能不能指点一下?苦恼死了
import javax.swing.*; //Packages used
import java.awt.*;
import java.awt.event.*;
public class AtmGUI extends JFrame
implements ActionListener{
private JButton confirm = new JButton("Confirm");
private JTextField input = new JTextField(20);
private JTextArea display = new JTextArea(5,20);
private KeyPad keypad = new KeyPad(this);
private FounctionPad founctionpad = new FounctionPad(this);
public AtmGUI(){
getContentPane().setLayout(new BorderLayout());
keypad = new KeyPad(this);
founctionpad = new FounctionPad(this);
getContentPane().add(input,"North"); //input
getContentPane().add(display,"Center"); //display
display.setLineWrap(true);
display.setEditable(false);
JPanel controlPanel = new JPanel(new BorderLayout(0,0)); //control panel
controlPanel.add(keypad,"Center");
controlPanel.add(confirm,"South");
getContentPane().add(controlPanel,"East");
getContentPane().add(founctionpad,"West"); //founction
confirm.addActionListener(this);
input.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
double cash = Double.valueOf(input.getText()).doubleValue();
display.append(cash+"\n");
input.setText("");
}
public void keypressCallback(String s){
if(s.equals("C"))
input.setText("");
else
input.setText(input.getText() + s);
}
public static void main(String args[]){
AtmGUI f = new AtmGUI();
f.setSize(400,300);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}