class calculadora extends JFrame {
public calculadora (){
//Display
final JTextField txtDato=new JTextField(20);
txtDato.setBounds(0, 0, 200, 30);
//botones de numeros
JButton btn1=new JButton("1");
btn1.setBounds(50,30,50,30);
btn1.addActionListener(new ActionListener(){
publicvoid actionPerformed (ActionEvent e){
}
});
JButton btn4=new JButton("4");
btn4.setBounds(50,60,50,30);
btn4.addActionListener(new ActionListener(){
publicvoid actionPerformed (ActionEvent e){
}
});
JButton btn7=new JButton("7");
btn7.setBounds(50,90,50,30);
btn7.addActionListener(new ActionListener(){
publicvoid actionPerformed (ActionEvent e){
}
});
JButton btn9=new JButton("9");
btn9.setBounds(150,90,50,30);
btn9.addActionListener(new ActionListener(){
publicvoid actionPerformed (ActionEvent e){
}
});
JButton btn2=new JButton("2");
btn2.setBounds(100,30,50,30);
btn2.addActionListener(new ActionListener(){
publicvoid actionPerformed (ActionEvent e){
}
});
JButton btn5=new JButton("5");
btn5.setBounds(100,60,50,30);
btn5.addActionListener(new ActionListener(){
publicvoid actionPerformed (ActionEvent e){
}
});
JButton btn8=new JButton("8");
btn8.setBounds(100,90,50,30);
btn8.addActionListener(new ActionListener(){
publicvoid actionPerformed (ActionEvent e){
}
});
JButton btn3=new JButton("3");
btn3.setBounds(150,30,50,30);
btn3.addActionListener(new ActionListener(){
publicvoid actionPerformed (ActionEvent e){
}
});
JButton btn6=new JButton("6");
btn6.setBounds(150,60,50,30);
btn6.addActionListener(new ActionListener(){
publicvoid actionPerformed (ActionEvent e){
}
});
JButton btn0=new JButton("0");
btn0.setBounds(100,120,50,30);
btn0.addActionListener(new ActionListener(){
publicvoid actionPerformed (ActionEvent e){
}
});
//botones de funciones
//
JButton btnCE=new JButton("CE");
btnCE.setBounds(150, 120, 50, 30);
btnCE.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent e){
}
});
JButton btnigual=new JButton("=");
btnigual.setBounds(50, 120, 50, 30);
btnigual.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent e) {
}
});
JButton btnSumar=new JButton("+");
btnSumar.setBounds(0, 30, 50, 30);
btnSumar.setMnemonic(KeyEvent.VK_S);
btnSumar.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent e) {
int a=Integer.parseInt(txtDato.getText());
}
});
JButton btnRestar=new JButton("-");
btnRestar.setBounds(0, 60, 50, 30);
btnRestar.setMnemonic(KeyEvent.VK_R);
btnRestar.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent e) {
}
});
JButton btnMultiplicar=new JButton("*");
btnMultiplicar.setBounds(0, 90, 50, 30);
btnMultiplicar.setMnemonic(KeyEvent.VK_M);
btnMultiplicar.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent e) {
}
});
JButton btnDividir=new JButton("/");
btnDividir.setBounds(0, 120, 50, 30);
btnDividir.setMnemonic(KeyEvent.VK_D);
btnDividir.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent e) {
;
}
})
;
//datos de la ventana
this.add(btnCE);
this.add(btn1);
this.add(btn2);
this.add(btn3);
this.add(btn4);
this.add(btn5);
this.add(btn6);
this.add(btn7);
this.add(btn8);
this.add(btn9);
this.add(btn0);
this.add(btnDividir);
this.add(btnMultiplicar);
this.add (btnMultiplicar);
this.setLayout(null);
this.add(btnRestar);
this.add(btnigual);
this.add(btnSumar);
this.add(txtDato);
this.setSize(210,183);
this.setTitle("Calculadora");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.getContentPane().setBackground(Color.DARK_GRAY);
this.setLocation(((Toolkit.getDefaultToolkit().getScreenSize().width-this.getSize().width)/2),
(Toolkit.getDefaultToolkit().getScreenSize().height-this.getSize().height)/2);
this.setVisible(true);
}
privatestaticfinallongserialVersionUID = 1L;
publicstaticvoid main(String[] args) {
new calculadora();
}
}