ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Calculador De Java


Enviado por   •  9 de Octubre de 2013  •  420 Palabras (2 Páginas)  •  338 Visitas

Página 1 de 2

import java.awt.*;

import java.applet.*;

import java.awt.event.*;

import java.lang.Math;

// <applet width="400" height="200" code="AppletInterfaz9"></applet>

public class panel extends Applet implements ActionListener{

Button b1, b2, b3, b4, b5, b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18;

TextField t1;

Panel p2;

Float n, s; // variables para uso dentro de todo el applet

int y; // variables para la comparcion

public panel() { // panel

setLayout(new BorderLayout());

p2 = new Panel(new GridLayout(6,3,10,10));

t1 = new TextField("",20);

b1 = new Button("1");

b2 = new Button("2");

b3 = new Button("3");

b4 = new Button("4");

b5 = new Button("5");

b6 = new Button("6");

b7 = new Button("7");

b8 = new Button("8");

b9 = new Button("9");

b10 = new Button(".");

b11 = new Button("0");

b12 = new Button("CE");

b13 = new Button("+");

b14 = new Button("-");

b15 = new Button("=");

b16 = new Button("*");

b17 = new Button("/");

b18 = new Button ("C");

p2.add(b1);

p2.add(b2);

p2.add(b3);

p2.add(b4);

p2.add(b5);

p2.add(b6);

p2.add(b7);

p2.add(b8);

p2.add(b9);

p2.add(b10);

p2.add(b11);

p2.add(b12);

p2.add(b13);

p2.add(b14);

p2.add(b15);

p2.add(b16);

p2.add(b17);

p2.add(b18);

add(t1,BorderLayout.NORTH);

add(p2,BorderLayout.CENTER);

b1.addActionListener (this);

b2.addActionListener (this);

b3.addActionListener (this);

b4.addActionListener (this);

b5.addActionListener (this);

b6.addActionListener (this);

b7.addActionListener (this);

b8.addActionListener (this);

b9.addActionListener (this);

b10.addActionListener (this);

b11.addActionListener (this);

b12.addActionListener (this);

b13.addActionListener (this);

b14.addActionListener (this);

b15.addActionListener (this);

b16.addActionListener (this);

b17.addActionListener (this);

b18.addActionListener (this);

}

public void actionPerformed(ActionEvent ae) {

String a = new String ("1");

if (ae.getSource()== b1){ // para agregar el numero indicado en comillas al cuadro de texto

t1.setText(""+t1.getText()+"1");

}

if (ae.getSource()== b2){ // para agregar el numero indicado en comillas al cuadro de texto

t1.setText(""+t1.getText()+"2");

}

if (ae.getSource()== b3){ // para agregar el numero indicado en comillas al cuadro de texto

t1.setText(""+t1.getText()+"3");

}

if (ae.getSource()== b4){// para agregar el numero indicado en comillas al cuadro de texto

t1.setText(""+t1.getText()+"4");

}

...

Descargar como (para miembros actualizados)  txt (4.7 Kb)  
Leer 1 página más »
Disponible sólo en Clubensayos.com