Ver Mensaje Individual
  #5 (permalink)  
Antiguo 25/11/2011, 11:12
luigimaldini
 
Fecha de Ingreso: octubre-2011
Mensajes: 90
Antigüedad: 12 años, 6 meses
Puntos: 1
Respuesta: Que componente utilizo?

ahi lo dejo:

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
class Calculadora extends JFrame {
JButton boton0 = new JButton("0");
JButton boton1 = new JButton("1");
JButton boton2 = new JButton("2");
JButton boton3 = new JButton("3");
JButton boton4 = new JButton("4");
JButton boton5 = new JButton("5");
JButton boton6 = new JButton("6");
JButton boton7 = new JButton("7");
JButton boton8 = new JButton("8");
JButton boton9 = new JButton("9");
JButton botonigual = new JButton("=");
JButton botonmenos = new JButton("-");
JButton botonmas = new JButton("+");
JButton botondivi = new JButton("/");
JButton botonmulti = new JButton("*");
JTextField texto = new JTextField(20);


public Calculadora() {
super("CALCULADORA");
setSize(400,400);
setVisible(true);

setLayout(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);

texto.setBounds(5,10,160,30);
boton1.setBounds(5,45,50,40);
boton2.setBounds(60,45,50,40);
boton3.setBounds(115,45,50,40);
boton4.setBounds(5,90,50,40);
boton5.setBounds(60,90,50,40);
boton6.setBounds(115,90,50,40);
boton7.setBounds(5,135,50,40);
boton8.setBounds(60,135,50,40);
boton9.setBounds(115,135,50,40);
botonmenos.setBounds(5,180,50,40);
boton0.setBounds(60,180,50,40);
botonmas.setBounds(115,180,50,40);
botondivi.setBounds(5,225,50,40);
botonigual.setBounds(60,225,50,40);
botonmulti.setBounds(115,225,50,40);


add(texto);
add(boton1);
add(boton2);
add(boton3);
add(boton4);
add(boton5);
add(boton6);
add(boton7);
add(boton8);
add(boton9);
add(botonmenos);
add(boton0);
add(botonmas);
add(botondivi);
add(botonigual);
add(botonmulti);


}

public void actionPerformed(ActionEvent e){
if (e.getSource()==boton1)
texto.setText("1");

}






}