密码

密码

import java.awt.*;
import javax.swing.*;
class CalButtonPane extends JPanel {
String[] keys = {"/","9","3","6","x","?","1",
"7","2",",","!","5","0","4",".",":","@","8","4",".","abc","中","五","拼","www"};
JButton[] keyb = new JButton[keys.length];
//JTextField t;
//JButton clear;
//double result = 0, value;
int i=0, j=0, l, math;
CalButtonPane(JTextField t){
super(new GridLayout(5, 5, 4, 4));
//this.t = t;
for( int i = 0; i <keys.length; i++ ) { keyb[i] = new JButton(keys[i]);
this.add(keyb[i]);
}
//clear = new JButton("Clear");
}
}
class Calculator extends JFrame {
JPanel p;
JTextField t;
CalButtonPane cp;
public Calculator() {
super("Java计算器");
setDefaultCloseOperation(EXIT_ON_CLOSE );
calInit();
Container cc = getContentPane();
cc.setLayout( new BorderLayout() );
//cc.add(t, "North" );
cc.add(cp, "Center" );
//cc.add(cp.clear, "South" );
this.setLocation(350, 250);
this.pack();
this.setResizable(false);
this.setVisible(true);
}
void calInit(){
t=new JTextField("0.0");
t.setHorizontalAlignment(JTextField.RIGHT);
cp=new CalButtonPane(t);
}
public static void main( String[] args ) {
new Calculator();
}
}

你可能感兴趣的:(密码)