Вы находитесь на странице: 1из 4

mail SEP SNEST

INSTITUTO TECNOLOGICO DE TOLUCA

MATERIA: Tópicos Selectos De Programación

CATEDRATICO: Imelda Verti Guzmán

ALUMNO: Carlos Alberto Rebollo Chávez

Tarea No 4 Calculadora,CheckBox,RadioButton,TextArea.

Metepec, México; Febrero 2011.


public class Operaciones {

int uno, dos;


int resultado;

public void Suma(double x, double y){

resultado= uno + dos;


System.out.println("la suma es:"+resultado );
System.exit( 0 );
}
public void Resta(double x, double y){

resultado=uno-dos;
System.out.println("la resta es:"+resultado );
System.exit( 0 );

public void Multiplicacion(double x, double y){

resultado=uno*dos;
System.out.println("la multiplicación es:"+resultado );
System.exit( 0 );
}

public void Division(double x, double y){

resultado= uno/dos;
System.out.println("la division es:"+resultado );
System.exit( 0 );

}
}
private class Axion implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
if ( event.getSource() == b1 )
t1.setText("0");
if(event.getSource()==b2)
t1.setText("1");
if ( event.getSource() == b3 )
t1.setText("2");
if ( event.getSource() == b4 )
t1.setText("3");
if ( event.getSource() == b5 )
t1.setText("4");
if ( event.getSource() == b6 )
t1.setText("5");
if ( event.getSource() == b7 )
t1.setText("6");
if ( event.getSource() == b8 )
t1.setText("7");
if ( event.getSource() == b9 )
t1.setText("8");
if ( event.getSource() == b10 )
t1.setText("9");
if ( event.getSource() == b11 )
t1.setText("+");
if ( event.getSource() == b12 )
t1.setText("-");
if ( event.getSource() == b13 )
t1.setText("*");
if ( event.getSource() == b14 )
t1.setText("/");

if ( event.getSource() == b17 )
t1.setText("(='.'=)");
} }

}
b11.addActionListener( Obj );
CALCULADORA b12.addActionListener( Obj );
b13.addActionListener( Obj );
b14.addActionListener( Obj );
b16.addActionListener(Obj);
b17.addActionListener(Obj);
import java.awt.BorderLayout; }
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout; public void lauchFrame(){
import java.awt.GridLayout; c = getContentPane();
import java.awt.event.ActionEvent; p1=new JPanel();
import java.awt.event.ActionListener; p1.setLayout(new GridLayout(3,5));
import javax.swing.JButton; p1.setBackground(Color.BLUE);
import javax.swing.JFrame; p1.add(b10);
import javax.swing.JPanel; p1.add(b9);
import javax.swing.JTextField; p1.add(b8);
p1.add(b7);
p1.add(b6);
public class calcu2 extends JFrame { p1.add(b5);
private JPanel p1,p2,p3; p1.add(b4);
private JTextField t1; p1.add(b3);
private JButton b1,b2,b3,b4,b5,b6,b7, p1.add(b2);
b8,b9,b10,b11,b12,b13,b14,b15, b16, b17; p1.add(b1);
Container c; p1.add(b16);
p1.add(b17);
public calcu2() p2=new JPanel();
{ p2.setLayout(new GridLayout(5,1));
super ("calcudoraaaa"); p2.setBackground(Color.red);
t1=new JTextField(20); p2.add(b11);
b1=new JButton("0"); p2.add(b12);
b2=new JButton("1"); p2.add(b13);
b3=new JButton("2"); p2.add(b14);
b4=new JButton("3"); p2.add(b15);
b5=new JButton("4"); p3=new JPanel();
b6=new JButton("5"); p3.setBackground(Color.BLACK);
b7=new JButton("6"); p3.add(t1);
b8=new JButton("7");
b9=new JButton("8"); //------------------------------------------------
b10=new JButton("9"); c.add(p3, BorderLayout.NORTH);
b11=new JButton("+"); c.add(p1, BorderLayout.CENTER);
b12=new JButton("-"); c.add(p2, BorderLayout.EAST);
b13=new JButton("*"); setSize(250,280);
b14=new JButton("/"); setVisible(true);
b15=new JButton("=");
b16=new JButton("+/-");
}
b17=new JButton("웃");
public static void main (String args[]){
=new Container();
calcu2 obj = new calcu2();
Axion Obj = new Axion(); obj.lauchFrame();
b1.addActionListener( Obj ); obj.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
b2.addActionListener( Obj ); }
b3.addActionListener( Obj );
b4.addActionListener( Obj );
b5.addActionListener( Obj );
b6.addActionListener( Obj );
b7.addActionListener( Obj );
b8.addActionListener( Obj );
b9.addActionListener( Obj );
b10.addActionListener( Obj );

Вам также может понравиться