All pastes #186546 Raw Edit

java code camilo

public java v1 · immutable
#186546 ·published 2006-09-30 03:30 UTC
rendered paste body
/*7 8 9 C CE4 5 6 * /1 2 3 + -0 .   =*/import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Calculator {	private static JTextField pantalla;	private static JButton boton1,boton2,boton3,boton4,boton5,boton6,boton7,boton8,boton9,boton10,boton11,boton12,boton13,	boton14,boton15,boton16,boton17,boton18	;		public static class Mostrador implements ActionListener{		public String tecla;				public Mostrador(String t){			tecla = t;		}				public void actionPerformed (ActionEvent e){						 pantalla.setText(pantalla.getText()+tecla);						}					}		public static class Operaciones implements ActionListener{		//en esta parte es donde no se como agarrar lo que aparece en el acmpo de texto de cada uno de                           //los botones cuando espicho click				public void actionPerformed (ActionEvent evento){						 String acumulador;			 acumulador = pantalla.getText();			 ulltimaoperacion "+";			 num2 = pantalla.getText();			 			 double num1 =0.0;			 double num2 =0.0;			 double suma =0.0;							 String ultimaOperacion;			 num1 = Double.parseDouble(acumulador);			 			 			 			 UltimaOperacion = +;			 						}					}		    	public static void main(String[] args) {		JFrame panel =new JFrame();		panel.setLayout(new BorderLayout());		JPanel teclado= new JPanel();		pantalla = new JTextField();		JPanel operadores= new JPanel();		panel.add(pantalla,BorderLayout.NORTH);		boton1= new JButton("1");		boton2= new JButton("2");		boton3= new JButton("3");		boton4= new JButton("4");		boton5= new JButton("5");		boton6= new JButton("6");		boton7= new JButton("7");		boton8= new JButton("8");		boton9= new JButton("9");		boton10= new JButton("*");		boton11= new JButton("0");		boton12= new JButton("#");		teclado.setLayout(new GridLayout(4,3));		teclado.add(boton1);		teclado.add(boton2);		teclado.add(boton3);		teclado.add(boton4);		teclado.add(boton5);		teclado.add(boton6);		teclado.add(boton7);		teclado.add(boton8);		teclado.add(boton9);		teclado.add(boton10);		teclado.add(boton11);		teclado.add(boton12);		panel.add(teclado,BorderLayout.CENTER);		boton1.addActionListener(new Mostrador("1"));		boton2.addActionListener(new Mostrador("2"));		boton3.addActionListener(new Mostrador("3"));		boton4.addActionListener(new Mostrador("4"));		boton5.addActionListener(new Mostrador("5"));		boton6.addActionListener(new Mostrador("6"));		boton7.addActionListener(new Mostrador("7"));		boton8.addActionListener(new Mostrador("8"));		boton9.addActionListener(new Mostrador("9"));		boton10.addActionListener(new Mostrador("0"));		boton11.addActionListener(new Mostrador("*"));		boton12.addActionListener(new Mostrador("."));		boton13= new JButton("*");		boton14= new JButton("/");		boton15= new JButton("-");		boton16= new JButton("+");		boton17= new JButton("=");		boton18= new JButton("c");		operadores.setLayout(new GridLayout(3,2));		operadores.add(boton13);		operadores.add(boton14);		operadores.add(boton15);		operadores.add(boton16);		operadores.add(boton17);		operadores.add(boton18);		panel.add(operadores,BorderLayout.EAST);		boton13.addActionListener(new Mostrador("*"));		boton14.addActionListener(new Mostrador("/"));		boton15.addActionListener(new Mostrador("-"));		boton16.addActionListener(new Mostrador("+"));		boton17.addActionListener(new Mostrador("="));		boton18.addActionListener(new Mostrador("c"));				panel.setSize(500,500);		panel.setVisible(true);