SlideShare una empresa de Scribd logo
1 de 11
Descargar para leer sin conexión
INFORME
ESTUDIANETE: Lenin Quishpe SEMESTRE: Segundo
PARALELO: C PRÁCTICA #21
TEMA:
Desarrollo de nuestra practica veintiuno en ECLIPSE.
OBJETIVO:
-Conocereldesarrollodeunprogramaen“Eclipse”,paraestedesarrollotendremosquecomprender
lo que son los formularios en Windows builder.
RESULTADOS DE APRENDIZAJE
-Comprensión de la aplicación de Eclipse.
-Uso correcto del código que aplicaremos en Eclipse.
-Aprender el uso correcto de los formularios
- Aprender a hacer operaciones básicas en un formulario
ACTIVIDADES:
-Realizarunprogramaenelqueingrese 3label,unoquediga:Operaciones Básicas,otroquediga:
ingrese el primer número y otro que diga: ingrese el segundo número en los 2 botones debe haber
untextfieldyenunúltimotextfieldpondremos elresultado;asícomoponer5botones,elprimero
paralasuma,elsegundoparalaresta,elterceroparalamultiplicación,elcuartoparaladivisiónyel
quinto para salir
DESARROLLO DE CONTENIDOS
1. Abrir la aplicación ECLIPSE.
2. Seleccionar la dirección en la que queramos guardar nuestro proyecto, en este caso lo vamos a
guardar en Escritorio (workspace).
3. Creamos un proyecto nuevo de Java.
4. Le ponemos un nombre a nuestro proyecto y le damos clic en Finish.
5. Dentro de nuestro nuevo proyecto crearemos un JFrame, le pondremos cualquier título.
6. Al crear un JFrame nos aparecerá el siguiente código, aquí podemos empezar a programar
7. Debemos ir a Design para entrar al formulario
8. Una vez que ingresemos al formulario podemos hacer las modificaciones que necesitemos
9. Pondremos 3label,unoquediga:OperacionesBásicas,otroquediga:ingreseelprimernúmeroy
otro que diga:ingrese el segundo número en los 2botones debe haberun textfield yen un último
textfieldpondremoselresultado;asícomoponer5botones,elprimeroparalasuma,elsegundo
parala resta, el terceropara la multiplicación, el cuarto parala división yel quintopara salir.
10. En el botón suma ingresaremos el siguiente código.
JButton btnNewButton = new JButton("SUMA");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
int num1, num2,suma;
num1=Integer.parseInt(textField.getText());
num2=Integer.parseInt(textField_1.getText());
suma=num1+num2;
textField_2.setText(String.valueOf(suma));
}
11. En el botón resta ingresaremos el siguiente código.
JButton btnNewButton_1 = new JButton("RESTA");
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) { int
num1, num2,resta;
num1=Integer.parseInt(textField.getText());
num2=Integer.parseInt(textField_1.getText());
resta=num1-num2;
textField_2.setText(String.valueOf(resta));
12. En el botón multiplicación ingresaremos el siguiente código.
JButton btnNewButton_2 = new JButton("MULTIPLICACIu00D3N");
btnNewButton_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) { int
num1, num2,multiplicacion;
num1=Integer.parseInt(textField.getText());
num2=Integer.parseInt(textField_1.getText());
multiplicacion=num1*num2;
textField_2.setText(String.valueOf(multiplicacion));
13. En el botón división ingresaremos el siguiente código.
JButton btnNewButton_3 = new JButton("DIVISIu00D3N");
btnNewButton_3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) { int
num1, num2,division;
num1=Integer.parseInt(textField.getText());
num2=Integer.parseInt(textField_1.getText());
division=num1/num2;
textField_2.setText(String.valueOf(division));
14. En el botón de salir ingresaremos el siguiente código, el cual nos va a permitir Salir del formulario.
JButton btnNewButton_1 = new JButton("SALIR");
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
System.exit(WIDTH);
}
verForm4.setVisible(true);
Form2.this.dispose();
15. Por último utilizaremos el botón para correr el programa y verificamos que no tenga
errores.
16.- Ingresaremos el primer y segundo número.
17.- Si le damos clic en suma nos desplegará el resultado
18.- Si le damos clic en resta nos desplegará el resultado
19.- Si le damos clic en multiplicación nos desplegará el resultado
20.- Si le damos clic en división nos desplegará el resultado
14.- Si le damos clic en SALIR se saldrá del programa
11.-Porúltimo,dejarélalíneadecódigoqueutilicé.Enelproyectooperaciónutilicéelsiguiente
código:
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Form5 extends JFrame {
private JPanel contentPane;
private JTextField textField;
private JTextField textField_1;
private JTextField textField_2;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Form5 frame = new Form5();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Form5() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblNewLabel = new JLabel("OPERACIONES Bu00C1SICAS");
lblNewLabel.setBounds(109, 11, 176, 60);
contentPane.add(lblNewLabel);
JLabel lblNewLabel_1 = new JLabel("INGRESE EL PRIMER
Nu00DAMERO");
lblNewLabel_1.setBounds(36, 82, 170, 14);
contentPane.add(lblNewLabel_1);
JLabel lblNewLabel_2 = new JLabel("INGRESE EL SEGUNDO NUMERO");
lblNewLabel_2.setBounds(36, 119, 154, 14);
contentPane.add(lblNewLabel_2);
textField = new JTextField();
textField.setBounds(216, 82, 86, 20);
contentPane.add(textField);
textField.setColumns(10);
textField_1 = new JTextField();
textField_1.setBounds(216, 116, 86, 20);
contentPane.add(textField_1);
textField_1.setColumns(10);
textField_2 = new JTextField();
textField_2.setBounds(146, 147, 86, 20);
contentPane.add(textField_2);
textField_2.setColumns(10);
JButton btnNewButton = new JButton("SUMA");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
int num1, num2,suma;
num1=Integer.parseInt(textField.getText());
num2=Integer.parseInt(textField_1.getText());
suma=num1+num2;
textField_2.setText(String.valueOf(suma));
}
});
btnNewButton.setBounds(10, 194, 89, 23);
contentPane.add(btnNewButton);
JButton btnNewButton_1 = new JButton("RESTA");
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) { int
num1, num2,resta;
num1=Integer.parseInt(textField.getText());
num2=Integer.parseInt(textField_1.getText());
resta=num1-num2;
textField_2.setText(String.valueOf(resta));
}
});
btnNewButton_1.setBounds(109, 194, 89, 23);
contentPane.add(btnNewButton_1);
JButton btnNewButton_2 = new JButton("MULTIPLICACIu00D3N");
btnNewButton_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) { int
num1, num2,multiplicacion;
num1=Integer.parseInt(textField.getText());
num2=Integer.parseInt(textField_1.getText());
multiplicacion=num1*num2;
textField_2.setText(String.valueOf(multiplicacion));
}
});
btnNewButton_2.setBounds(208, 194, 86, 23);
contentPane.add(btnNewButton_2);
JButton btnNewButton_3 = new JButton("DIVISIu00D3N");
btnNewButton_3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) { int
num1, num2,division;
num1=Integer.parseInt(textField.getText());
num2=Integer.parseInt(textField_1.getText());
division=num1/num2;
textField_2.setText(String.valueOf(division));
}
});
btnNewButton_3.setBounds(304, 194, 89, 23);
contentPane.add(btnNewButton_3);
JButton btnNewButton_4 = new JButton("SALIR");
btnNewButton_4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
System.exit(0);
}
});
btnNewButton_4.setBounds(146, 228, 89, 23);
contentPane.add(btnNewButton_4);
}
}
f.)
____ _______ f.) __________________
MSc. Víctor Zapata
ESTUDIANTE DOCENTE

Más contenido relacionado

La actualidad más candente (20)

In 19
In 19In 19
In 19
 
Editable
EditableEditable
Editable
 
In 3
In 3In 3
In 3
 
In 9
In 9In 9
In 9
 
In 4
In 4In 4
In 4
 
In 13
In 13In 13
In 13
 
In 6
In 6In 6
In 6
 
In 14
In 14In 14
In 14
 
In 8
In 8In 8
In 8
 
Informe#7
Informe#7Informe#7
Informe#7
 
Informe#10
Informe#10Informe#10
Informe#10
 
Informe#15
Informe#15Informe#15
Informe#15
 
Informe#5
Informe#5Informe#5
Informe#5
 
Formulario u4tema4
Formulario u4tema4Formulario u4tema4
Formulario u4tema4
 
Informe#13
Informe#13Informe#13
Informe#13
 
Informe#21
Informe#21Informe#21
Informe#21
 
Informe#14
Informe#14Informe#14
Informe#14
 
Informe#12
Informe#12Informe#12
Informe#12
 
10
1010
10
 
10 porta
10 porta10 porta
10 porta
 

Similar a In 21 (20)

21
2121
21
 
21 porta
21 porta21 porta
21 porta
 
Informe#20
Informe#20Informe#20
Informe#20
 
Informe#19
Informe#19Informe#19
Informe#19
 
Informe#18
Informe#18Informe#18
Informe#18
 
24
2424
24
 
Pract 5
Pract 5Pract 5
Pract 5
 
20
2020
20
 
20 por
20 por20 por
20 por
 
18 por
18 por18 por
18 por
 
18
1818
18
 
Unidad 4 tema 3
Unidad 4  tema 3Unidad 4  tema 3
Unidad 4 tema 3
 
Unid 4 tema 4
Unid 4  tema 4Unid 4  tema 4
Unid 4 tema 4
 
Informe#23
Informe#23Informe#23
Informe#23
 
22
2222
22
 
Informe#25
Informe#25Informe#25
Informe#25
 
Informe tecnico eventos
Informe tecnico   eventosInforme tecnico   eventos
Informe tecnico eventos
 
Informe#17
Informe#17Informe#17
Informe#17
 
23
2323
23
 
Practica 11
Practica 11Practica 11
Practica 11
 

Más de LENINMATEO1 (20)

Examen
ExamenExamen
Examen
 
Chatbot
ChatbotChatbot
Chatbot
 
Cheque
ChequeCheque
Cheque
 
Ejercicios basicos php lenin quishpe
Ejercicios basicos php lenin quishpeEjercicios basicos php lenin quishpe
Ejercicios basicos php lenin quishpe
 
Tabla de multiplicar con for y while
Tabla de multiplicar con for y whileTabla de multiplicar con for y while
Tabla de multiplicar con for y while
 
Tabla de multiplicar con for
Tabla de multiplicar con forTabla de multiplicar con for
Tabla de multiplicar con for
 
Tabla de multiplicar con while
Tabla de multiplicar con whileTabla de multiplicar con while
Tabla de multiplicar con while
 
Tarea con switch
Tarea con switchTarea con switch
Tarea con switch
 
Uso de variables en php
Uso de variables en phpUso de variables en php
Uso de variables en php
 
In 29
In 29In 29
In 29
 
In 28
In 28In 28
In 28
 
In 27
In 27In 27
In 27
 
In 26
In 26In 26
In 26
 
In 25
In 25In 25
In 25
 
In 24
In 24In 24
In 24
 
In 23
In 23In 23
In 23
 
In 22
In 22In 22
In 22
 
In 21
In 21In 21
In 21
 
In 20
In 20In 20
In 20
 
In 18
In 18In 18
In 18
 

Último

Introducción:Los objetivos de Desarrollo Sostenible
Introducción:Los objetivos de Desarrollo SostenibleIntroducción:Los objetivos de Desarrollo Sostenible
Introducción:Los objetivos de Desarrollo SostenibleJonathanCovena1
 
codigos HTML para blogs y paginas web Karina
codigos HTML para blogs y paginas web Karinacodigos HTML para blogs y paginas web Karina
codigos HTML para blogs y paginas web Karinavergarakarina022
 
PRIMER SEMESTRE 2024 ASAMBLEA DEPARTAMENTAL.pptx
PRIMER SEMESTRE 2024 ASAMBLEA DEPARTAMENTAL.pptxPRIMER SEMESTRE 2024 ASAMBLEA DEPARTAMENTAL.pptx
PRIMER SEMESTRE 2024 ASAMBLEA DEPARTAMENTAL.pptxinformacionasapespu
 
Neurociencias para Educadores NE24 Ccesa007.pdf
Neurociencias para Educadores  NE24  Ccesa007.pdfNeurociencias para Educadores  NE24  Ccesa007.pdf
Neurociencias para Educadores NE24 Ccesa007.pdfDemetrio Ccesa Rayme
 
OLIMPIADA DEL CONOCIMIENTO INFANTIL 2024.pptx
OLIMPIADA DEL CONOCIMIENTO INFANTIL 2024.pptxOLIMPIADA DEL CONOCIMIENTO INFANTIL 2024.pptx
OLIMPIADA DEL CONOCIMIENTO INFANTIL 2024.pptxjosetrinidadchavez
 
RETO MES DE ABRIL .............................docx
RETO MES DE ABRIL .............................docxRETO MES DE ABRIL .............................docx
RETO MES DE ABRIL .............................docxAna Fernandez
 
SINTAXIS DE LA ORACIÓN SIMPLE 2023-2024.pptx
SINTAXIS DE LA ORACIÓN SIMPLE 2023-2024.pptxSINTAXIS DE LA ORACIÓN SIMPLE 2023-2024.pptx
SINTAXIS DE LA ORACIÓN SIMPLE 2023-2024.pptxlclcarmen
 
Planificacion Anual 2do Grado Educacion Primaria 2024 Ccesa007.pdf
Planificacion Anual 2do Grado Educacion Primaria   2024   Ccesa007.pdfPlanificacion Anual 2do Grado Educacion Primaria   2024   Ccesa007.pdf
Planificacion Anual 2do Grado Educacion Primaria 2024 Ccesa007.pdfDemetrio Ccesa Rayme
 
GLOSAS Y PALABRAS ACTO 2 DE ABRIL 2024.docx
GLOSAS  Y PALABRAS ACTO 2 DE ABRIL 2024.docxGLOSAS  Y PALABRAS ACTO 2 DE ABRIL 2024.docx
GLOSAS Y PALABRAS ACTO 2 DE ABRIL 2024.docxAleParedes11
 
CALENDARIZACION DE MAYO / RESPONSABILIDAD
CALENDARIZACION DE MAYO / RESPONSABILIDADCALENDARIZACION DE MAYO / RESPONSABILIDAD
CALENDARIZACION DE MAYO / RESPONSABILIDADauxsoporte
 
SELECCIÓN DE LA MUESTRA Y MUESTREO EN INVESTIGACIÓN CUALITATIVA.pdf
SELECCIÓN DE LA MUESTRA Y MUESTREO EN INVESTIGACIÓN CUALITATIVA.pdfSELECCIÓN DE LA MUESTRA Y MUESTREO EN INVESTIGACIÓN CUALITATIVA.pdf
SELECCIÓN DE LA MUESTRA Y MUESTREO EN INVESTIGACIÓN CUALITATIVA.pdfAngélica Soledad Vega Ramírez
 
Caja de herramientas de inteligencia artificial para la academia y la investi...
Caja de herramientas de inteligencia artificial para la academia y la investi...Caja de herramientas de inteligencia artificial para la academia y la investi...
Caja de herramientas de inteligencia artificial para la academia y la investi...Lourdes Feria
 
EXPANSIÓN ECONÓMICA DE OCCIDENTE LEÓN.pptx
EXPANSIÓN ECONÓMICA DE OCCIDENTE LEÓN.pptxEXPANSIÓN ECONÓMICA DE OCCIDENTE LEÓN.pptx
EXPANSIÓN ECONÓMICA DE OCCIDENTE LEÓN.pptxPryhaSalam
 
Heinsohn Privacidad y Ciberseguridad para el sector educativo
Heinsohn Privacidad y Ciberseguridad para el sector educativoHeinsohn Privacidad y Ciberseguridad para el sector educativo
Heinsohn Privacidad y Ciberseguridad para el sector educativoFundación YOD YOD
 
Planificacion Anual 4to Grado Educacion Primaria 2024 Ccesa007.pdf
Planificacion Anual 4to Grado Educacion Primaria   2024   Ccesa007.pdfPlanificacion Anual 4to Grado Educacion Primaria   2024   Ccesa007.pdf
Planificacion Anual 4to Grado Educacion Primaria 2024 Ccesa007.pdfDemetrio Ccesa Rayme
 
DECÁGOLO DEL GENERAL ELOY ALFARO DELGADO
DECÁGOLO DEL GENERAL ELOY ALFARO DELGADODECÁGOLO DEL GENERAL ELOY ALFARO DELGADO
DECÁGOLO DEL GENERAL ELOY ALFARO DELGADOJosé Luis Palma
 
DE LAS OLIMPIADAS GRIEGAS A LAS DEL MUNDO MODERNO.ppt
DE LAS OLIMPIADAS GRIEGAS A LAS DEL MUNDO MODERNO.pptDE LAS OLIMPIADAS GRIEGAS A LAS DEL MUNDO MODERNO.ppt
DE LAS OLIMPIADAS GRIEGAS A LAS DEL MUNDO MODERNO.pptELENA GALLARDO PAÚLS
 

Último (20)

Introducción:Los objetivos de Desarrollo Sostenible
Introducción:Los objetivos de Desarrollo SostenibleIntroducción:Los objetivos de Desarrollo Sostenible
Introducción:Los objetivos de Desarrollo Sostenible
 
La Trampa De La Felicidad. Russ-Harris.pdf
La Trampa De La Felicidad. Russ-Harris.pdfLa Trampa De La Felicidad. Russ-Harris.pdf
La Trampa De La Felicidad. Russ-Harris.pdf
 
codigos HTML para blogs y paginas web Karina
codigos HTML para blogs y paginas web Karinacodigos HTML para blogs y paginas web Karina
codigos HTML para blogs y paginas web Karina
 
PRIMER SEMESTRE 2024 ASAMBLEA DEPARTAMENTAL.pptx
PRIMER SEMESTRE 2024 ASAMBLEA DEPARTAMENTAL.pptxPRIMER SEMESTRE 2024 ASAMBLEA DEPARTAMENTAL.pptx
PRIMER SEMESTRE 2024 ASAMBLEA DEPARTAMENTAL.pptx
 
Neurociencias para Educadores NE24 Ccesa007.pdf
Neurociencias para Educadores  NE24  Ccesa007.pdfNeurociencias para Educadores  NE24  Ccesa007.pdf
Neurociencias para Educadores NE24 Ccesa007.pdf
 
OLIMPIADA DEL CONOCIMIENTO INFANTIL 2024.pptx
OLIMPIADA DEL CONOCIMIENTO INFANTIL 2024.pptxOLIMPIADA DEL CONOCIMIENTO INFANTIL 2024.pptx
OLIMPIADA DEL CONOCIMIENTO INFANTIL 2024.pptx
 
RETO MES DE ABRIL .............................docx
RETO MES DE ABRIL .............................docxRETO MES DE ABRIL .............................docx
RETO MES DE ABRIL .............................docx
 
Defendamos la verdad. La defensa es importante.
Defendamos la verdad. La defensa es importante.Defendamos la verdad. La defensa es importante.
Defendamos la verdad. La defensa es importante.
 
SINTAXIS DE LA ORACIÓN SIMPLE 2023-2024.pptx
SINTAXIS DE LA ORACIÓN SIMPLE 2023-2024.pptxSINTAXIS DE LA ORACIÓN SIMPLE 2023-2024.pptx
SINTAXIS DE LA ORACIÓN SIMPLE 2023-2024.pptx
 
Presentacion Metodología de Enseñanza Multigrado
Presentacion Metodología de Enseñanza MultigradoPresentacion Metodología de Enseñanza Multigrado
Presentacion Metodología de Enseñanza Multigrado
 
Planificacion Anual 2do Grado Educacion Primaria 2024 Ccesa007.pdf
Planificacion Anual 2do Grado Educacion Primaria   2024   Ccesa007.pdfPlanificacion Anual 2do Grado Educacion Primaria   2024   Ccesa007.pdf
Planificacion Anual 2do Grado Educacion Primaria 2024 Ccesa007.pdf
 
GLOSAS Y PALABRAS ACTO 2 DE ABRIL 2024.docx
GLOSAS  Y PALABRAS ACTO 2 DE ABRIL 2024.docxGLOSAS  Y PALABRAS ACTO 2 DE ABRIL 2024.docx
GLOSAS Y PALABRAS ACTO 2 DE ABRIL 2024.docx
 
CALENDARIZACION DE MAYO / RESPONSABILIDAD
CALENDARIZACION DE MAYO / RESPONSABILIDADCALENDARIZACION DE MAYO / RESPONSABILIDAD
CALENDARIZACION DE MAYO / RESPONSABILIDAD
 
SELECCIÓN DE LA MUESTRA Y MUESTREO EN INVESTIGACIÓN CUALITATIVA.pdf
SELECCIÓN DE LA MUESTRA Y MUESTREO EN INVESTIGACIÓN CUALITATIVA.pdfSELECCIÓN DE LA MUESTRA Y MUESTREO EN INVESTIGACIÓN CUALITATIVA.pdf
SELECCIÓN DE LA MUESTRA Y MUESTREO EN INVESTIGACIÓN CUALITATIVA.pdf
 
Caja de herramientas de inteligencia artificial para la academia y la investi...
Caja de herramientas de inteligencia artificial para la academia y la investi...Caja de herramientas de inteligencia artificial para la academia y la investi...
Caja de herramientas de inteligencia artificial para la academia y la investi...
 
EXPANSIÓN ECONÓMICA DE OCCIDENTE LEÓN.pptx
EXPANSIÓN ECONÓMICA DE OCCIDENTE LEÓN.pptxEXPANSIÓN ECONÓMICA DE OCCIDENTE LEÓN.pptx
EXPANSIÓN ECONÓMICA DE OCCIDENTE LEÓN.pptx
 
Heinsohn Privacidad y Ciberseguridad para el sector educativo
Heinsohn Privacidad y Ciberseguridad para el sector educativoHeinsohn Privacidad y Ciberseguridad para el sector educativo
Heinsohn Privacidad y Ciberseguridad para el sector educativo
 
Planificacion Anual 4to Grado Educacion Primaria 2024 Ccesa007.pdf
Planificacion Anual 4to Grado Educacion Primaria   2024   Ccesa007.pdfPlanificacion Anual 4to Grado Educacion Primaria   2024   Ccesa007.pdf
Planificacion Anual 4to Grado Educacion Primaria 2024 Ccesa007.pdf
 
DECÁGOLO DEL GENERAL ELOY ALFARO DELGADO
DECÁGOLO DEL GENERAL ELOY ALFARO DELGADODECÁGOLO DEL GENERAL ELOY ALFARO DELGADO
DECÁGOLO DEL GENERAL ELOY ALFARO DELGADO
 
DE LAS OLIMPIADAS GRIEGAS A LAS DEL MUNDO MODERNO.ppt
DE LAS OLIMPIADAS GRIEGAS A LAS DEL MUNDO MODERNO.pptDE LAS OLIMPIADAS GRIEGAS A LAS DEL MUNDO MODERNO.ppt
DE LAS OLIMPIADAS GRIEGAS A LAS DEL MUNDO MODERNO.ppt
 

In 21

  • 1. INFORME ESTUDIANETE: Lenin Quishpe SEMESTRE: Segundo PARALELO: C PRÁCTICA #21 TEMA: Desarrollo de nuestra practica veintiuno en ECLIPSE. OBJETIVO: -Conocereldesarrollodeunprogramaen“Eclipse”,paraestedesarrollotendremosquecomprender lo que son los formularios en Windows builder. RESULTADOS DE APRENDIZAJE -Comprensión de la aplicación de Eclipse. -Uso correcto del código que aplicaremos en Eclipse. -Aprender el uso correcto de los formularios - Aprender a hacer operaciones básicas en un formulario ACTIVIDADES: -Realizarunprogramaenelqueingrese 3label,unoquediga:Operaciones Básicas,otroquediga: ingrese el primer número y otro que diga: ingrese el segundo número en los 2 botones debe haber untextfieldyenunúltimotextfieldpondremos elresultado;asícomoponer5botones,elprimero paralasuma,elsegundoparalaresta,elterceroparalamultiplicación,elcuartoparaladivisiónyel quinto para salir DESARROLLO DE CONTENIDOS 1. Abrir la aplicación ECLIPSE. 2. Seleccionar la dirección en la que queramos guardar nuestro proyecto, en este caso lo vamos a guardar en Escritorio (workspace).
  • 2. 3. Creamos un proyecto nuevo de Java. 4. Le ponemos un nombre a nuestro proyecto y le damos clic en Finish. 5. Dentro de nuestro nuevo proyecto crearemos un JFrame, le pondremos cualquier título.
  • 3. 6. Al crear un JFrame nos aparecerá el siguiente código, aquí podemos empezar a programar 7. Debemos ir a Design para entrar al formulario 8. Una vez que ingresemos al formulario podemos hacer las modificaciones que necesitemos
  • 4. 9. Pondremos 3label,unoquediga:OperacionesBásicas,otroquediga:ingreseelprimernúmeroy otro que diga:ingrese el segundo número en los 2botones debe haberun textfield yen un último textfieldpondremoselresultado;asícomoponer5botones,elprimeroparalasuma,elsegundo parala resta, el terceropara la multiplicación, el cuarto parala división yel quintopara salir. 10. En el botón suma ingresaremos el siguiente código. JButton btnNewButton = new JButton("SUMA"); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int num1, num2,suma; num1=Integer.parseInt(textField.getText()); num2=Integer.parseInt(textField_1.getText()); suma=num1+num2; textField_2.setText(String.valueOf(suma)); } 11. En el botón resta ingresaremos el siguiente código. JButton btnNewButton_1 = new JButton("RESTA"); btnNewButton_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int num1, num2,resta; num1=Integer.parseInt(textField.getText()); num2=Integer.parseInt(textField_1.getText()); resta=num1-num2; textField_2.setText(String.valueOf(resta));
  • 5. 12. En el botón multiplicación ingresaremos el siguiente código. JButton btnNewButton_2 = new JButton("MULTIPLICACIu00D3N"); btnNewButton_2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int num1, num2,multiplicacion; num1=Integer.parseInt(textField.getText()); num2=Integer.parseInt(textField_1.getText()); multiplicacion=num1*num2; textField_2.setText(String.valueOf(multiplicacion)); 13. En el botón división ingresaremos el siguiente código. JButton btnNewButton_3 = new JButton("DIVISIu00D3N"); btnNewButton_3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int num1, num2,division; num1=Integer.parseInt(textField.getText()); num2=Integer.parseInt(textField_1.getText()); division=num1/num2; textField_2.setText(String.valueOf(division)); 14. En el botón de salir ingresaremos el siguiente código, el cual nos va a permitir Salir del formulario. JButton btnNewButton_1 = new JButton("SALIR"); btnNewButton_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.exit(WIDTH); } verForm4.setVisible(true); Form2.this.dispose(); 15. Por último utilizaremos el botón para correr el programa y verificamos que no tenga errores. 16.- Ingresaremos el primer y segundo número. 17.- Si le damos clic en suma nos desplegará el resultado
  • 6. 18.- Si le damos clic en resta nos desplegará el resultado 19.- Si le damos clic en multiplicación nos desplegará el resultado 20.- Si le damos clic en división nos desplegará el resultado
  • 7. 14.- Si le damos clic en SALIR se saldrá del programa 11.-Porúltimo,dejarélalíneadecódigoqueutilicé.Enelproyectooperaciónutilicéelsiguiente código: import java.awt.BorderLayout; import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; import javax.swing.JLabel; import javax.swing.JTextField; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class Form5 extends JFrame { private JPanel contentPane; private JTextField textField; private JTextField textField_1; private JTextField textField_2; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Form5 frame = new Form5(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); }
  • 8. } }); } /** * Create the frame. */ public Form5() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 450, 300); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JLabel lblNewLabel = new JLabel("OPERACIONES Bu00C1SICAS"); lblNewLabel.setBounds(109, 11, 176, 60); contentPane.add(lblNewLabel); JLabel lblNewLabel_1 = new JLabel("INGRESE EL PRIMER Nu00DAMERO"); lblNewLabel_1.setBounds(36, 82, 170, 14); contentPane.add(lblNewLabel_1); JLabel lblNewLabel_2 = new JLabel("INGRESE EL SEGUNDO NUMERO"); lblNewLabel_2.setBounds(36, 119, 154, 14); contentPane.add(lblNewLabel_2); textField = new JTextField(); textField.setBounds(216, 82, 86, 20); contentPane.add(textField); textField.setColumns(10); textField_1 = new JTextField(); textField_1.setBounds(216, 116, 86, 20); contentPane.add(textField_1); textField_1.setColumns(10); textField_2 = new JTextField(); textField_2.setBounds(146, 147, 86, 20); contentPane.add(textField_2); textField_2.setColumns(10); JButton btnNewButton = new JButton("SUMA"); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int num1, num2,suma; num1=Integer.parseInt(textField.getText()); num2=Integer.parseInt(textField_1.getText()); suma=num1+num2; textField_2.setText(String.valueOf(suma)); } }); btnNewButton.setBounds(10, 194, 89, 23);
  • 9. contentPane.add(btnNewButton); JButton btnNewButton_1 = new JButton("RESTA"); btnNewButton_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int num1, num2,resta; num1=Integer.parseInt(textField.getText()); num2=Integer.parseInt(textField_1.getText()); resta=num1-num2; textField_2.setText(String.valueOf(resta)); } }); btnNewButton_1.setBounds(109, 194, 89, 23); contentPane.add(btnNewButton_1); JButton btnNewButton_2 = new JButton("MULTIPLICACIu00D3N"); btnNewButton_2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int num1, num2,multiplicacion; num1=Integer.parseInt(textField.getText()); num2=Integer.parseInt(textField_1.getText()); multiplicacion=num1*num2; textField_2.setText(String.valueOf(multiplicacion)); } }); btnNewButton_2.setBounds(208, 194, 86, 23); contentPane.add(btnNewButton_2); JButton btnNewButton_3 = new JButton("DIVISIu00D3N"); btnNewButton_3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int num1, num2,division; num1=Integer.parseInt(textField.getText()); num2=Integer.parseInt(textField_1.getText()); division=num1/num2; textField_2.setText(String.valueOf(division)); } }); btnNewButton_3.setBounds(304, 194, 89, 23); contentPane.add(btnNewButton_3); JButton btnNewButton_4 = new JButton("SALIR"); btnNewButton_4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.exit(0); } }); btnNewButton_4.setBounds(146, 228, 89, 23); contentPane.add(btnNewButton_4);
  • 10. } }
  • 11. f.) ____ _______ f.) __________________ MSc. Víctor Zapata ESTUDIANTE DOCENTE