Vous êtes sur la page 1sur 27

INSTITUTO TECNOLGICO SUPERIOR DE SAN ANDRS TUXTLA

UNIDAD 2 INTERFZ GRAFICA DE USUARIO

TPICOS AVANZADOS DE PROGRAMACIN MATERIA

SERGIO REYES RODRIGUEZ NOMBRE

INGENIERIA EN SISTEMAS COMPUTACIONALES CARRERA

404 B GRUPO

MTI. ANGELINA MRQUEZ JIMENEZ DOCENTE

08 DE ABRIL DE 2013 FECHA DE ENTREGA

PROGRAMA 1:

operaciones.java

import javax.swing.JOptionPane; public class operaciones { public static void main( String args [] ) { int valor=0, opcion; int number1=0; int number2=0; do { String operacion = JOptionPane.showInputDialog(null, "seleccione 1 para sumar\n" + "seleccione 2 para restar\n" + "seleccione 3 para multiplicar\n"+ "seleccione 4 para dividir\n"+ "seleccione 5 para salir", "SELECCIONE LA OPERACION A REALIZAR", JOptionPane.PLAIN_MESSAGE); opcion=Integer.parseInt(operacion); if (opcion==5) { System.exit(0); } if((opcion>=1)&&(opcion<=4)) { String firstNumber = JOptionPane.showInputDialog( "seleccione el primer entero" ); String secondNumber = JOptionPane.showInputDialog( "seleccione el segundo entero" ); number1=Integer.parseInt(firstNumber); number2=Integer.parseInt(secondNumber);

} switch(opcion) { case 1: valor=number1 + number2; JOptionPane.showMessageDialog(null, "EL RESULTADO ES: " + valor," *****OPERACION DE DOS ENTEROS*****", JOptionPane.PLAIN_MESSAGE); break; case 2: valor=number1 - number2; JOptionPane.showMessageDialog(null, "EL RESULTADO ES: " + valor," *****OPERACION DE DOS ENTEROS*****", JOptionPane.PLAIN_MESSAGE); break; case 3: valor=number1 * number2; JOptionPane.showMessageDialog(null, "EL RESULTADO ES: " + valor," *****OPERACION DE DOS ENTEROS*****", JOptionPane.PLAIN_MESSAGE); break; case 4: valor=number1 / number2; JOptionPane.showMessageDialog(null, "EL RESULTADO ES: " + valor," *****OPERACION DE DOS ENTEROS*****", JOptionPane.PLAIN_MESSAGE); break; default: JOptionPane.showMessageDialog(null, "USTED OPRIMIO UNA OPCION INCORRECTA: "," ", JOptionPane.ERROR_MESSAGE); } }while (opcion!=5);

} }

GUA DE OBSERVACIN
INSTRUCCIONES Revisar los documentos o actividades que se solicitan y marque en los apartados SI cuando la evidencia a evaluar se cumpla, en caso contrario marque NO. En la columna OBSERVACIONES, ocpela cuando tenga que hacer comentarios referentes a lo observado. Asignatura : TPICOS AVANZADOS DE PROGRAMACIN No. De Equipo : 0 Tema: Programacin de Interfaz Grfica de usuario

Alumno : Sergio Reyes Rodrguez

CARACTERSTICAS A CUMPLIR

CUMPL E SI N O 3% 3% 3% CUMPLE SI NO

OBSERVACIONES

Desarrollo Emplea Listeners Emplea JFrame y JButton en el programa Emplea la librera awt o swing en su programa CARACTERSTICAS A CUMPLIR
Resultados:

OBSERVACIONES

El programa correctamente sintcticos.


Responsabilidad:

se sin

ejecuta 3% errores

Termin el programa en el tiempo 3% sealado. TOTAL DE REACTIVOS: 15%

15%

PROGRAMA 2: ENT.JAVA

import java.awt.event.ActionEvent; import javax.swing.*; import java.awt.event.*; public class ENT extends JFrame implements ActionListener{ private JTextField campoTxt; private JTextField campoTxt2; private JLabel etiqueta; private JLabel etiqueta2; private JLabel etiquetaRes; private JLabel etiquetaT; private JButton botonAceptar; private JButton botonLimpiar; int resT, number1, number2;

public ENT() { setLayout(null); etiqueta=new JLabel("DATO 1:"); etiqueta.setBounds(15, 10, 100, 25); add(etiqueta) campoTxt=new JTextField(); campoTxt.setBounds(120,10,150,25); add(campoTxt); setLayout(null); etiqueta2=new JLabel("DATO 2:"); etiqueta2.setBounds(15, 40, 100, 25); add(etiqueta2); campoTxt2=new JTextField(); campoTxt2.setBounds(120,40,150,25); add(campoTxt2);

setLayout(null); etiquetaRes=new JLabel("RESULTADO = "+resT); etiquetaRes.setBounds(15, 70, 100, 30); add(etiquetaRes); botonAceptar=new JButton("ACEPTAR"); botonAceptar.setBounds(10,120,100,30); add(botonAceptar); botonAceptar.addActionListener(this); botonLimpiar=new JButton("LIMPIAR"); botonLimpiar.setBounds(170,120,100,30); add(botonLimpiar); botonLimpiar.addActionListener(this); } public boolean isVacio(String datoFuente) { if(datoFuente.length()==0) return(true); else return(false); } public boolean noEsNumerico(String datoFuente) { try { Integer.parseInt(datoFuente); return (false); }catch (NumberFormatException er) { return true; } } public boolean validacion(String fuente1, String fuente2) { boolean bandera=false;// significa que no hay errores

if(isVacio(fuente1))

{ JOptionPane.showMessageDialog(null,"a intoducido valores no numericos", "ERROR",JOptionPane.ERROR_MESSAGE ); bandera=true; } if(isVacio(fuente2)) { JOptionPane.showMessageDialog(null,"a intoducido valores no numericos EN DATO2", "ERROR",JOptionPane.ERROR_MESSAGE );

bandera=true; } if ( noEsNumerico(fuente1)) { JOptionPane.showMessageDialog(null,"a intoducido valores no numericos", "ERROR",JOptionPane.ERROR_MESSAGE ); bandera=true; } if ( noEsNumerico(fuente2)) { JOptionPane.showMessageDialog(null,"a intoducido valores no numericos EN DATO2", "ERROR",JOptionPane.ERROR_MESSAGE ); bandera=true; }

return bandera; } public void actionPerformed(ActionEvent e){

if(e.getSource()==botonAceptar) { if (validacion(campoTxt.getText(), campoTxt2.getText())==false)// convertimos a numerico { String dato1=campoTxt.getText(); number1=Integer.parseInt(dato1); String dato2=campoTxt2.getText(); number2=Integer.parseInt(dato2); resT=number1+number2; etiquetaRes.setText("RESULTADO = "+resT); setTitle("el RESULTADO total de LA SUMA ES"); } } if(e.getSource()==botonLimpiar) { setTitle(" "); campoTxt.setText(null); campoTxt2.setText(null); etiquetaRes.setText("RESULTADO = "); } } public static void main(String []arg) { ENT ent=new ENT(); ent.setBounds(0,0,300,200); ent.setResizable(false); ent.setVisible(true); ent.setDefaultCloseOperation(EXIT_ON_CLOSE); } }

GUA DE OBSERVACIN
INSTRUCCIONES Revisar los documentos o actividades que se solicitan y marque en los apartados SI cuando la evidencia a evaluar se cumpla, en caso contrario marque NO. En la columna OBSERVACIONES, ocpela cuando tenga que hacer comentarios referentes a lo observado. Asignatura : TPICOS AVANZADOS DE PROGRAMACIN No. De Equipo : 0 Tema: Programacin de Interfaz Grfica de usuario

Alumno : Sergio Reyes Rodrguez

CARACTERSTICAS A CUMPLIR Desarrollo Emplea Listeners Emplea JFrame y JButton en el programa Emplea la librera awt o swing en su programa

CUMPLE SI NO 3% 3% 3%

OBSERVACIONES

CARACTERSTICAS A CUMPLIR
Resultados:

CUMPLE SI NO

OBSERVACIONES

El programa correctamente sintcticos.


Responsabilidad:

se sin

ejecuta 3% errores

Termin el programa en el tiempo 3% sealado. TOTAL DE REACTIVOS: 15%

15%

PROGRAMA 3. Minical2.java
import javax.swing.*; import java.awt.event.*; public class minical2 extends JFrame implements ActionListener { private JTextField campoTxt, campoTxt2; private JLabel etiqueta1, etiqueta2, etiqueta3; private JButton botonSumar, botonCE, botonRestar, botonMultiplicar, botonDividir; double n1=0,n2=0; double sum=0; double res=0; double mul=0; double div=0; public minical2() { setLayout(null); etiqueta1 = new JLabel ("Dato 1 : "); etiqueta1.setBounds (30, 20, 100, 30); add(etiqueta1); etiqueta2 = new JLabel ("Dato 2 : "); etiqueta2.setBounds (30, 70, 100, 30); add(etiqueta2); etiqueta3 = new JLabel ("Resultado = "); etiqueta3.setBounds (30, 100, 350, 30); add(etiqueta3); campoTxt = new JTextField (); campoTxt.setBounds (100, 20, 100, 20); add(campoTxt);

campoTxt2 = new JTextField (); campoTxt2.setBounds (100, 70, 100, 20); add(campoTxt2);

botonSumar = new JButton ("Sumar"); botonSumar.setBounds (10, 200, 90, 20); add(botonSumar); botonSumar.addActionListener(this); botonCE = new JButton ("CE"); botonCE.setBounds (430, 200, 90, 20); add(botonCE); botonCE.addActionListener(this); botonRestar = new JButton ("Restar"); botonRestar.setBounds (110, 200, 90, 20); add(botonRestar); botonRestar.addActionListener(this); botonMultiplicar = new JButton ("Multiplicar"); botonMultiplicar.setBounds (210, 200, 90, 20); add(botonMultiplicar); botonMultiplicar.addActionListener(this); botonDividir = new JButton ("Dividir"); botonDividir.setBounds (320, 200, 90, 20); add(botonDividir); botonDividir.addActionListener(this); } public boolean isVacio(String datoFuente) { if(datoFuente.length()==0) return(true); else return(false); }

public boolean NoesNumerico(String datoFuente) { try{ Double.parseDouble(datoFuente); return(false); }catch(NumberFormatException er) { return(true); } }

public boolean validacion(String fuente1,String fuente2) { boolean band = false; if(isVacio(fuente1)) { JOptionPane.showMessageDialog(null,"No Inserto dato 1 "," ",JOptionPane.PLAIN_MESSAGE); band=true; } if (isVacio(fuente2)) { JOptionPane.showMessageDialog(null,"No Inserto dato 2 "," ",JOptionPane.PLAIN_MESSAGE); band=true; } if(NoesNumerico(fuente1)) { JOptionPane.showMessageDialog(null,"No es numerico dato 1","ERROR",JOptionPane.PLAIN_MESSAGE); band=true; } if (NoesNumerico(fuente2)) {

JOptionPane.showMessageDialog(null,"No es numerico dato 2"," ERROR",JOptionPane.PLAIN_MESSAGE); band=true; } return band; }

public void actionPerformed(ActionEvent e) { setTitle("mini calculadora "); if(e.getSource() == botonCE) { campoTxt.setText(null); campoTxt2.setText(null); etiqueta3.setText("El resultado es "); }

if(e.getSource() == botonSumar) {

if (validacion(campoTxt.getText(),campoTxt2.getText())==false) { String num1 = campoTxt.getText(); n1 = Double.parseDouble(num1); String num2 = campoTxt2.getText(); n2 = Double.parseDouble(num2);

sum =n1+n2; etiqueta3.setText("El resultado es "+sum); } } if(e.getSource() == botonRestar) { if (validacion(campoTxt.getText(),campoTxt2.getText())==false) { String num1 = campoTxt.getText(); n1 = Double.parseDouble(num1); String num2 = campoTxt2.getText(); n2 = Double.parseDouble(num2); res =n1-n2; etiqueta3.setText("El resultado es "+res); } } if(e.getSource() == botonMultiplicar) { if (validacion(campoTxt.getText(),campoTxt2.getText())==false) {

String num1 = campoTxt.getText(); n1 = Double.parseDouble(num1); String num2 = campoTxt2.getText(); n2 = Double.parseDouble(num2); mul =n1*n2; etiqueta3.setText("El resultado es "+mul); } } if(e.getSource() == botonDividir) {

if (validacion(campoTxt.getText(),campoTxt2.getText())==false) {

String num1 = campoTxt.getText(); n1 = Double.parseDouble(num1); String num2 = campoTxt2.getText(); n2 = Double.parseDouble(num2); div =n1/n2; etiqueta3.setText("El resulado es "+div); } } if (e.getSource()== botonSumar) { { } } } public static void main(String [] arg) { minical2 ent = new minical2(); ent.setBounds (500, 250, 550, 350); ent.setVisible (true); ent.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); }

GUA DE OBSERVACIN
INSTRUCCIONES Revisar los documentos o actividades que se solicitan y marque en los apartados SI cuando la evidencia a evaluar se cumpla, en caso contrario marque NO. En la columna OBSERVACIONES, ocpela cuando tenga que hacer comentarios referentes a lo observado. Asignatura : TPICOS AVANZADOS DE PROGRAMACIN No. De Equipo : 0 Tema: Programacin de Interfaz Grfica de usuario

Alumno : Sergio Reyes Rodrguez

CARACTERSTICAS A CUMPLIR Desarrollo Emplea Listeners Emplea JFrame y JButton en el programa Emplea la librera awt o swing en su programa

CUMPLE SI NO 3% 3% 3%

OBSERVACIONES

CARACTERSTICAS A CUMPLIR
Resultados:

CUMPLE SI NO

OBSERVACIONES

El programa correctamente sintcticos.


Responsabilidad:

se sin

ejecuta 3% errores

Termin el programa en el tiempo 3% sealado. TOTAL DE REACTIVOS: 15%

15%

Programa 4. cuotaHipoteca.java
import javax.swing.*; import java.awt.event.*; public class cuotaHipoteca extends JFrame implements ActionListener { private JTextField campoTxt, campoTxt2, campoTxt3; private JLabel etiqueta1, etiqueta2, etiqueta3, etiqueta4; private JButton botonAceptar, botonLimpiar,botonCalcular,botonRestar,botonDividir,botonMultiplicar; double n1=0,n2=0, n3=0; double sum;

public cuotaHipoteca () { setTitle("Calculo de la cuota de la hipoteca"); setLayout(null); etiqueta1 = new JLabel ("Cantidad : "); etiqueta1.setBounds (30, 20, 100, 30); add(etiqueta1); etiqueta2 = new JLabel ("Aos : "); etiqueta2.setBounds (250, 20, 100, 30); add(etiqueta2); etiqueta3 = new JLabel ("Interes Mensual = "); etiqueta3.setBounds (450, 20, 350, 30); add(etiqueta3); etiqueta4 = new JLabel ("Cuota Mensual a Pagar = "); etiqueta4.setBounds (30,90, 350, 30); add(etiqueta4);

campoTxt = new JTextField (); campoTxt.setBounds (100, 20, 100, 20); add(campoTxt); campoTxt2 = new JTextField (); campoTxt2.setBounds (300, 20, 100, 20); add(campoTxt2);

campoTxt3 = new JTextField (); campoTxt3.setBounds (600, 20, 100, 20); add(campoTxt3);

botonLimpiar = new JButton ("Limpiar"); botonLimpiar.setBounds (240, 150, 150, 20); add(botonLimpiar); botonLimpiar.addActionListener(this); botonCalcular = new JButton (" Calcular "); botonCalcular.setBounds (10, 150, 150, 20); add(botonCalcular); botonCalcular.addActionListener(this);

} public boolean isVacio(String datoFuente) { if(datoFuente.length()==0) return(true); else return(false); } public boolean NoesNumerico(String datoFuente) { try{

Double.parseDouble(datoFuente); return(false); }catch(NumberFormatException er) { return(true); } } public boolean validacion(String fuente1,String fuente2) { boolean band=false; if(isVacio(fuente1)) { JOptionPane.showMessageDialog(null,"No Inserto El dato 1 "," Intente De Nuevo ",JOptionPane.PLAIN_MESSAGE); band=true; } if (isVacio(fuente2)) { JOptionPane.showMessageDialog(null,"No Inserto El dato 2 "," Intente De Nuevo ",JOptionPane.PLAIN_MESSAGE); band=true; } if(NoesNumerico(fuente1)) {JOptionPane.showMessageDialog(null,"El dato 1 no es numerico "," Intente De Nuevo ",JOptionPane.PLAIN_MESSAGE); band=true; } if(NoesNumerico(fuente2)) {JOptionPane.showMessageDialog(null,"El dato 2 no es numerico "," Intente De Nuevo ",JOptionPane.PLAIN_MESSAGE); band=true; }

return band; }

public void actionPerformed(ActionEvent e) { if(e.getSource() == botonCalcular) { if (validacion(campoTxt.getText(),campoTxt2.getText())==false) { String num1 = campoTxt.getText(); n1 = Double.parseDouble(num1); String num2 = campoTxt2.getText(); n2 = Double.parseDouble(num2); String num3 = campoTxt3.getText(); n3 = Double.parseDouble(num3); sum =(n1*n2*(n3/100))/(12*n2);

etiqueta4.setText("LA CUOTA A PAGAR ES "+sum);

} }

if(e.getSource() == botonLimpiar) { //setTitle("La suma es "); campoTxt.setText(null);

campoTxt2.setText(null); campoTxt3.setText(null); etiqueta4.setText("El resultado final es "); } } public static void main(String [] arg) { cuotaHipoteca ent = new cuotaHipoteca(); ent.setBounds (500, 350, 800, 250); ent.setVisible (true); ent.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); }

GUA DE OBSERVACIN
INSTRUCCIONES Revisar los documentos o actividades que se solicitan y marque en los apartados SI cuando la evidencia a evaluar se cumpla, en caso contrario marque NO. En la columna OBSERVACIONES, ocpela cuando tenga que hacer comentarios referentes a lo observado. Asignatura : TPICOS AVANZADOS DE PROGRAMACIN No. De Equipo : 0 Tema: Programacin de Interfaz Grfica de usuario (cuotaH.java)

Alumno :Sergio Reyes Rodrguez

CARACTERSTICAS A CUMPLIR Desarrollo Emplea ActionListener Emplea JFrame y JButton en el programa Implement validacin en todos los JTextField

CUMPLE SI NO 1% 1% 10%

OBSERVACIONES

CARACTERSTICAS A CUMPLIR
Resultados:

CUMPLE SI NO

OBSERVACIONES

El programa captura errores en 10% tiempo de ejecucin y enva el mensaje correspondiente.


Responsabilidad:

Termin el programa en el tiempo 3% sealado. TOTAL DE REACTIVOS: 25%

25%

Vous aimerez peut-être aussi