INFORME
ESTUDIANTE: Jefferson Paul Cuenca Tenecela SEMESTRE: SEGUNDO
PARALELO: C PRÁCTICA:24
TEMA:
Desarrollo de nuestro primer programa
OBJETIVO:
-Conocer el desarrollo de un programa en “Eclipse”, para este desarrollo tendremos
que comprender 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:
-Realizar un programa en el que se registre y contabilice los votos de las
personas que sufragan.
DESARROLLO DE CONTENIDOS
1. Abrir ECLIPSE.
2. Seleccionar la dirección en la que queramos guardar nuestro proyecto, en este
caso lo vamos a guardar en Escritorio (Desktop).
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. En el primer formulario pondremos los siguientes datos:
- 4 botones que digan: Lista 21, Lista 5, Nulo y Blanco
- 2 Label para poner las imágenes de los 2 posibles presidentes
- 1 Botón para imprimir resultados en el segundo formulario
10. En el segundo formulario pondremos los siguientes datos:
- 4 Text Fields en los que se guarden los resultados
- 1 Botón para imprimir resultados en un Text Field
11. En el botón resultados ingresaremos el siguiente código, no olvidemos que
algunos puntos deben estar en público
private int count=0;
public void actionPerformed(ActionEvent arg0) {
count ++;
RESULTADOS verRESULTADOS=new RESULTADOS ();
String n=String.valueOf(count);
JOptionPane.showMessageDialog(null,"Gracias por su voto");
R1.setText(n);
}
});
btnNewButton.setBounds(57, 103, 119, 38);
contentPane.add(btnNewButton);
voto");
JButton btnNewButton_1 = new JButton("LISTA 1 ");
btnNewButton_1.addActionListener(new ActionListener() {
private int count=0;
public void actionPerformed(ActionEvent arg0) {
count ++;
RESULTADOS verRESULTADOS=new RESULTADOS ();
String n=String.valueOf(count);
JOptionPane.showMessageDialog(null,"Gracias por su
R2.setText(n);
}
});
btnNewButton_1.setBounds(251, 103, 101, 38);
contentPane.add(btnNewButton_1);
JButton btnNewButton_2 = new JButton("NULO");
btnNewButton_2.addActionListener(new ActionListener() {
private int count=0;
public void actionPerformed(ActionEvent arg0) {
count ++;
RESULTADOS verRESULTADOS=new RESULTADOS ();
String n=String.valueOf(count);
voto");
});
JOptionPane.showMessageDialog(null,"Gracias por su
R3.setText(n);
}
btnNewButton_2.setBounds(57, 152, 119, 33);
contentPane.add(btnNewButton_2);
voto");
JButton btnNewButton_3 = new JButton("BLANCO ");
btnNewButton_3.addActionListener(new ActionListener() {
int count=0;
public void actionPerformed(ActionEvent arg0) {
count ++;
RESULTADOS verRESULTADOS=new RESULTADOS ();
String n=String.valueOf(count);
JOptionPane.showMessageDialog(null,"Gracias por su
R4.setText(n);
}
});
btnNewButton_3.setBounds(251, 152, 101, 32);
contentPane.add(btnNewButton_3);
JButton btnNewButton_4 = new JButton("RESULTADOS");
btnNewButton_4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
RESULTADOS abrir=new RESULTADOS ();
abrir.setVisible(true);
String inf=R1.getText();
abrir.creo.setText(inf);
String inf2=R2.getText();
abrir.centro.setText(inf2);
String inf3=R3.getText();
abrir.blanco.setText(inf3);
String inf4=R4.getText();
abrir.nulo.setText(inf4);
}
});
btnNewButton_4.setBounds(160, 214, 101, 23);
contentPane.add(btnNewButton_4);
R1 = new JTextField();
R1.setBounds(104, 117, 11, 10);
contentPane.add(R1);
R1.setColumns(10);
R2 = new JTextField();
R2.setBounds(302, 117, 11, 10);
contentPane.add(R2);
R2.setColumns(10);
R3 = new JTextField();
R3.setBounds(104, 163,
contentPane.add(R3);
11, 10);
R3.setColumns(10);
R4 = new JTextField();
R4.setBounds(302, 163,
contentPane.add(R4);
11, 10);
R4.setColumns(10);
T = new JTextField();
T.setBounds(207, 220, 11, 10);
contentPane.add(T);
T.setColumns(10);
12.- En el segundo Formulario también debe estar en público y utilizaremos el siguiente
código
JButton btnNewButton_2 = new JButton("TOTAL");
btnNewButton_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
int a,b,c,d,f;
a=Integer.parseInt(centro.getText());
b=Integer.parseInt(creo.getText());
c=Integer.parseInt(blanco.getText());
d=Integer.parseInt(nulo.getText());
f=a+b+c+d;
t.setText(String.valueOf(f));
13. – Correremos el programa
14.- Por último, dejaré la línea de código que utilicé en el primer formulario:
package cne;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel; import
javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import javax.swing.text.JTextComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon; import
java.awt.Component;
public class CNE extends JFrame {
private JPanel contentPane;
private JTextField R1;
private JTextField R2;
private JTextField R3;
private JTextField R4;
private JTextField T;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
CNE frame = new CNE();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
/**
}
}
});
* Create the frame.
*/
public CNE() {
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("ELECCIONES
"); lblNewLabel.setBounds(178, 0, 83, 25);
contentPane.add(lblNewLabel);
JLabel lblNewLabel_2 = new
JLabel("ARAUZ"); lblNewLabel_2.setIcon(new
ImageIcon("C:UsersmiltoDesktopara.jpg")); lblNewLabel_2.setBounds(251,
31, 101, 69); contentPane.add(lblNewLabel_2);
JButton btnNewButton = new JButton("LISTA CREO ");
btnNewButton.addActionListener(new ActionListener() {
private int count=0;
public void actionPerformed(ActionEvent arg0) {
count ++;
RESULTADOS verRESULTADOS=new RESULTADOS ();
String n=String.valueOf(count);
JOptionPane.showMessageDialog(null,"Gracias por su voto");
R1.setText(n);
}
});
btnNewButton.setBounds(57, 103, 119, 38);
contentPane.add(btnNewButton);
voto");
JButton btnNewButton_1 = new JButton("LISTA 1 ");
btnNewButton_1.addActionListener(new ActionListener() {
private int count=0;
public void actionPerformed(ActionEvent arg0) {
count ++;
RESULTADOS verRESULTADOS=new RESULTADOS ();
String n=String.valueOf(count);
JOptionPane.showMessageDialog(null,"Gracias por su
R2.setText(n);
}
});
btnNewButton_1.setBounds(251, 103, 101, 38);
contentPane.add(btnNewButton_1);
voto");
JButton btnNewButton_2 = new JButton("NULO");
btnNewButton_2.addActionListener(new ActionListener() {
private int count=0;
public void actionPerformed(ActionEvent arg0) {
count ++;
RESULTADOS verRESULTADOS=new RESULTADOS ();
String n=String.valueOf(count);
JOptionPane.showMessageDialog(null,"Gracias por su
R3.setText(n);
}
});
btnNewButton_2.setBounds(57, 152, 119, 33);
voto");
contentPane.add(btnNewButton_2);
JButton btnNewButton_3 = new JButton("BLANCO ");
btnNewButton_3.addActionListener(new ActionListener() {
int count=0;
public void actionPerformed(ActionEvent arg0) {
count ++;
RESULTADOS verRESULTADOS=new RESULTADOS ();
String n=String.valueOf(count);
JOptionPane.showMessageDialog(null,"Gracias por su
R4.setText(n);
}
});
btnNewButton_3.setBounds(251, 152, 101, 32);
contentPane.add(btnNewButton_3);
JButton btnNewButton_4 = new JButton("RESULTADOS");
btnNewButton_4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
RESULTADOS abrir=new RESULTADOS
();
abrir.setVisible(true); String
inf=R1.getText();
abrir.creo.setText(inf); String
inf2=R2.getText();
abrir.centro.setText(inf2);
String inf3=R3.getText();
abrir.blanco.setText(inf3);
String inf4=R4.getText();
abrir.nulo.setText(inf4);
}
});
btnNewButton_4.setBounds(160, 214, 101, 23);
contentPane.add(btnNewButton_4);
R1 = new JTextField(); R1.setBounds(104,
117, 11, 10);
contentPane.add(R1);
R1.setColumns(10);
R2 = new JTextField(); R2.setBounds(302,
117, 11, 10);
contentPane.add(R2); R2.setColumns(10);
R3 = new JTextField(); R3.setBounds(104,
163, 11, 10);
contentPane.add(R3); R3.setColumns(10);
R4 = new JTextField(); R4.setBounds(302,
163, 11, 10);
contentPane.add(R4); R4.setColumns(10);
T = new JTextField(); T.setBounds(207,
220, 11, 10);
contentPane.add(T);
T.setColumns(10);
JLabel lblNewLabel_3 = new JLabel("LASSO");
lblNewLabel_3.setIcon(new
ImageIcon("C:UsersmiltoDesktoplassodef.jpg"));
lblNewLabel_3.setBounds(75, 28, 101, 75);
contentPane.add(lblNewLabel_3);
}
}
15.- Por último, dejaré la línea de código que utilicé en el segundo formulario:
package cne;
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;
import javax.swing.ImageIcon;
public class RESULTADOS extends JFrame {
private JPanel contentPane;
public JTextField centro;
public JTextField blanco;
public JTextField nulo;
public JTextField creo;
public JTextField t;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
RESULTADOS frame = new RESULTADOS();
frame.setVisible(true);
} catch (Exception e) {
}
/**
}
});
e.printStackTrace();
}
* Create the frame.
*/
public RESULTADOS() {
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("RESULTADOS
FINALES"); lblNewLabel.setBounds(136, 11, 175, 49);
contentPane.add(lblNewLabel);
JLabel lblNewLabel_1 = new JLabel("LISTA CREO");
lblNewLabel_1.setBounds(40, 82, 79, 33);
contentPane.add(lblNewLabel_1);
JLabel lblNewLabel_2 = new JLabel("LISTA CINCO");
lblNewLabel_2.setBounds(40, 115, 66, 33);
contentPane.add(lblNewLabel_2);
JLabel lblNewLabel_3 = new JLabel("BLANCOS ");
lblNewLabel_3.setBounds(40, 159, 79, 27);
contentPane.add(lblNewLabel_3);
JLabel lblNewLabel_4 = new JLabel(" NULOS");
lblNewLabel_4.setBounds(40, 197, 46, 14);
contentPane.add(lblNewLabel_4);
centro = new JTextField();
centro.setBounds(136, 121, 86, 20);
contentPane.add(centro);
centro.setColumns(10);
blanco = new JTextField();
blanco.setBounds(136, 162, 86, 20);
contentPane.add(blanco);
blanco.setColumns(10);
nulo = new JTextField();
nulo.setBounds(136, 194, 86, 20);
contentPane.add(nulo);
nulo.setColumns(10);
creo = new JTextField();
creo.setBounds(136, 88, 86, 20);
contentPane.add(creo);
creo.setColumns(10);
t = new JTextField(); t.setBounds(136,
225, 86, 20); contentPane.add(t);
t.setColumns(10);
JButton btnNewButton = new JButton("REGRESAR");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
CNE abrir= new CNE();
abrir.setVisible(true);
setVisible(false);
}
});
btnNewButton.setBounds(304, 120, 89, 23);
contentPane.add(btnNewButton);
JButton btnNewButton_1 = new JButton("SALIR");
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
System.exit(0);
}
});
btnNewButton_1.setBounds(304, 193, 89, 23);
contentPane.add(btnNewButton_1);
JButton btnNewButton_2 = new JButton("TOTAL");
btnNewButton_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) { int
a,b,c,d,f;
a=Integer.parseInt(centro.getText());
b=Integer.parseInt(creo.getText());
c=Integer.parseInt(blanco.getText());
d=Integer.parseInt(nulo.getText());
f=a+b+c+d;
t.setText(String.valueOf(f));
}
});
btnNewButton_2.setBounds(17, 224, 89, 23);
contentPane.add(btnNewButton_2);
}
}

Informe#25

  • 1.
    INFORME ESTUDIANTE: Jefferson PaulCuenca Tenecela SEMESTRE: SEGUNDO PARALELO: C PRÁCTICA:24 TEMA: Desarrollo de nuestro primer programa OBJETIVO: -Conocer el desarrollo de un programa en “Eclipse”, para este desarrollo tendremos que comprender 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: -Realizar un programa en el que se registre y contabilice los votos de las personas que sufragan. DESARROLLO DE CONTENIDOS 1. Abrir ECLIPSE.
  • 2.
    2. Seleccionar ladirección en la que queramos guardar nuestro proyecto, en este caso lo vamos a guardar en Escritorio (Desktop). 3. Creamos un proyecto nuevo de Java. 4. Le ponemos un nombre a nuestro proyecto y le damos clic en Finish.
  • 3.
    5. Dentro denuestro 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
  • 4.
    8. Una vezque ingresemos al formulario podemos hacer las modificaciones que necesitemos 9. En el primer formulario pondremos los siguientes datos: - 4 botones que digan: Lista 21, Lista 5, Nulo y Blanco - 2 Label para poner las imágenes de los 2 posibles presidentes - 1 Botón para imprimir resultados en el segundo formulario 10. En el segundo formulario pondremos los siguientes datos: - 4 Text Fields en los que se guarden los resultados - 1 Botón para imprimir resultados en un Text Field
  • 5.
    11. En elbotón resultados ingresaremos el siguiente código, no olvidemos que algunos puntos deben estar en público private int count=0; public void actionPerformed(ActionEvent arg0) { count ++; RESULTADOS verRESULTADOS=new RESULTADOS (); String n=String.valueOf(count); JOptionPane.showMessageDialog(null,"Gracias por su voto"); R1.setText(n); } }); btnNewButton.setBounds(57, 103, 119, 38); contentPane.add(btnNewButton); voto"); JButton btnNewButton_1 = new JButton("LISTA 1 "); btnNewButton_1.addActionListener(new ActionListener() { private int count=0; public void actionPerformed(ActionEvent arg0) { count ++; RESULTADOS verRESULTADOS=new RESULTADOS (); String n=String.valueOf(count); JOptionPane.showMessageDialog(null,"Gracias por su R2.setText(n); } }); btnNewButton_1.setBounds(251, 103, 101, 38); contentPane.add(btnNewButton_1); JButton btnNewButton_2 = new JButton("NULO"); btnNewButton_2.addActionListener(new ActionListener() { private int count=0; public void actionPerformed(ActionEvent arg0) { count ++; RESULTADOS verRESULTADOS=new RESULTADOS (); String n=String.valueOf(count);
  • 6.
    voto"); }); JOptionPane.showMessageDialog(null,"Gracias por su R3.setText(n); } btnNewButton_2.setBounds(57,152, 119, 33); contentPane.add(btnNewButton_2); voto"); JButton btnNewButton_3 = new JButton("BLANCO "); btnNewButton_3.addActionListener(new ActionListener() { int count=0; public void actionPerformed(ActionEvent arg0) { count ++; RESULTADOS verRESULTADOS=new RESULTADOS (); String n=String.valueOf(count); JOptionPane.showMessageDialog(null,"Gracias por su R4.setText(n); } }); btnNewButton_3.setBounds(251, 152, 101, 32); contentPane.add(btnNewButton_3); JButton btnNewButton_4 = new JButton("RESULTADOS"); btnNewButton_4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { RESULTADOS abrir=new RESULTADOS (); abrir.setVisible(true); String inf=R1.getText(); abrir.creo.setText(inf); String inf2=R2.getText(); abrir.centro.setText(inf2); String inf3=R3.getText(); abrir.blanco.setText(inf3); String inf4=R4.getText(); abrir.nulo.setText(inf4); } }); btnNewButton_4.setBounds(160, 214, 101, 23); contentPane.add(btnNewButton_4); R1 = new JTextField(); R1.setBounds(104, 117, 11, 10); contentPane.add(R1); R1.setColumns(10); R2 = new JTextField(); R2.setBounds(302, 117, 11, 10); contentPane.add(R2); R2.setColumns(10); R3 = new JTextField(); R3.setBounds(104, 163, contentPane.add(R3); 11, 10); R3.setColumns(10); R4 = new JTextField(); R4.setBounds(302, 163, contentPane.add(R4); 11, 10); R4.setColumns(10);
  • 7.
    T = newJTextField(); T.setBounds(207, 220, 11, 10); contentPane.add(T); T.setColumns(10); 12.- En el segundo Formulario también debe estar en público y utilizaremos el siguiente código JButton btnNewButton_2 = new JButton("TOTAL"); btnNewButton_2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int a,b,c,d,f; a=Integer.parseInt(centro.getText()); b=Integer.parseInt(creo.getText()); c=Integer.parseInt(blanco.getText()); d=Integer.parseInt(nulo.getText()); f=a+b+c+d; t.setText(String.valueOf(f)); 13. – Correremos el programa 14.- Por último, dejaré la línea de código que utilicé en el primer formulario: package cne; import java.awt.BorderLayout; import java.awt.EventQueue;
  • 8.
    import javax.swing.JFrame; import javax.swing.JPanel;import javax.swing.JTextField; import javax.swing.border.EmptyBorder; import javax.swing.text.JTextComponent; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.ImageIcon; import java.awt.Component; public class CNE extends JFrame { private JPanel contentPane; private JTextField R1; private JTextField R2; private JTextField R3; private JTextField R4; private JTextField T; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { CNE frame = new CNE(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } /** } } }); * Create the frame. */ public CNE() { 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("ELECCIONES "); lblNewLabel.setBounds(178, 0, 83, 25); contentPane.add(lblNewLabel);
  • 9.
    JLabel lblNewLabel_2 =new JLabel("ARAUZ"); lblNewLabel_2.setIcon(new ImageIcon("C:UsersmiltoDesktopara.jpg")); lblNewLabel_2.setBounds(251, 31, 101, 69); contentPane.add(lblNewLabel_2); JButton btnNewButton = new JButton("LISTA CREO "); btnNewButton.addActionListener(new ActionListener() { private int count=0; public void actionPerformed(ActionEvent arg0) { count ++; RESULTADOS verRESULTADOS=new RESULTADOS (); String n=String.valueOf(count); JOptionPane.showMessageDialog(null,"Gracias por su voto"); R1.setText(n); } }); btnNewButton.setBounds(57, 103, 119, 38); contentPane.add(btnNewButton); voto"); JButton btnNewButton_1 = new JButton("LISTA 1 "); btnNewButton_1.addActionListener(new ActionListener() { private int count=0; public void actionPerformed(ActionEvent arg0) { count ++; RESULTADOS verRESULTADOS=new RESULTADOS (); String n=String.valueOf(count); JOptionPane.showMessageDialog(null,"Gracias por su R2.setText(n); } }); btnNewButton_1.setBounds(251, 103, 101, 38); contentPane.add(btnNewButton_1); voto"); JButton btnNewButton_2 = new JButton("NULO"); btnNewButton_2.addActionListener(new ActionListener() { private int count=0; public void actionPerformed(ActionEvent arg0) { count ++; RESULTADOS verRESULTADOS=new RESULTADOS (); String n=String.valueOf(count); JOptionPane.showMessageDialog(null,"Gracias por su R3.setText(n); } }); btnNewButton_2.setBounds(57, 152, 119, 33);
  • 10.
    voto"); contentPane.add(btnNewButton_2); JButton btnNewButton_3 =new JButton("BLANCO "); btnNewButton_3.addActionListener(new ActionListener() { int count=0; public void actionPerformed(ActionEvent arg0) { count ++; RESULTADOS verRESULTADOS=new RESULTADOS (); String n=String.valueOf(count); JOptionPane.showMessageDialog(null,"Gracias por su R4.setText(n); } }); btnNewButton_3.setBounds(251, 152, 101, 32); contentPane.add(btnNewButton_3); JButton btnNewButton_4 = new JButton("RESULTADOS"); btnNewButton_4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { RESULTADOS abrir=new RESULTADOS (); abrir.setVisible(true); String inf=R1.getText(); abrir.creo.setText(inf); String inf2=R2.getText(); abrir.centro.setText(inf2); String inf3=R3.getText(); abrir.blanco.setText(inf3); String inf4=R4.getText(); abrir.nulo.setText(inf4); } }); btnNewButton_4.setBounds(160, 214, 101, 23); contentPane.add(btnNewButton_4); R1 = new JTextField(); R1.setBounds(104, 117, 11, 10); contentPane.add(R1); R1.setColumns(10); R2 = new JTextField(); R2.setBounds(302, 117, 11, 10); contentPane.add(R2); R2.setColumns(10); R3 = new JTextField(); R3.setBounds(104, 163, 11, 10); contentPane.add(R3); R3.setColumns(10);
  • 11.
    R4 = newJTextField(); R4.setBounds(302, 163, 11, 10); contentPane.add(R4); R4.setColumns(10); T = new JTextField(); T.setBounds(207, 220, 11, 10); contentPane.add(T); T.setColumns(10); JLabel lblNewLabel_3 = new JLabel("LASSO"); lblNewLabel_3.setIcon(new ImageIcon("C:UsersmiltoDesktoplassodef.jpg")); lblNewLabel_3.setBounds(75, 28, 101, 75); contentPane.add(lblNewLabel_3); } } 15.- Por último, dejaré la línea de código que utilicé en el segundo formulario: package cne; 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; import javax.swing.ImageIcon; public class RESULTADOS extends JFrame { private JPanel contentPane; public JTextField centro; public JTextField blanco; public JTextField nulo; public JTextField creo; public JTextField t; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { RESULTADOS frame = new RESULTADOS(); frame.setVisible(true); } catch (Exception e) {
  • 12.
    } /** } }); e.printStackTrace(); } * Create theframe. */ public RESULTADOS() { 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("RESULTADOS FINALES"); lblNewLabel.setBounds(136, 11, 175, 49); contentPane.add(lblNewLabel); JLabel lblNewLabel_1 = new JLabel("LISTA CREO"); lblNewLabel_1.setBounds(40, 82, 79, 33); contentPane.add(lblNewLabel_1); JLabel lblNewLabel_2 = new JLabel("LISTA CINCO"); lblNewLabel_2.setBounds(40, 115, 66, 33); contentPane.add(lblNewLabel_2); JLabel lblNewLabel_3 = new JLabel("BLANCOS "); lblNewLabel_3.setBounds(40, 159, 79, 27); contentPane.add(lblNewLabel_3); JLabel lblNewLabel_4 = new JLabel(" NULOS"); lblNewLabel_4.setBounds(40, 197, 46, 14); contentPane.add(lblNewLabel_4); centro = new JTextField(); centro.setBounds(136, 121, 86, 20); contentPane.add(centro); centro.setColumns(10); blanco = new JTextField(); blanco.setBounds(136, 162, 86, 20); contentPane.add(blanco); blanco.setColumns(10); nulo = new JTextField(); nulo.setBounds(136, 194, 86, 20); contentPane.add(nulo); nulo.setColumns(10); creo = new JTextField(); creo.setBounds(136, 88, 86, 20);
  • 13.
    contentPane.add(creo); creo.setColumns(10); t = newJTextField(); t.setBounds(136, 225, 86, 20); contentPane.add(t); t.setColumns(10); JButton btnNewButton = new JButton("REGRESAR"); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { CNE abrir= new CNE(); abrir.setVisible(true); setVisible(false); } }); btnNewButton.setBounds(304, 120, 89, 23); contentPane.add(btnNewButton); JButton btnNewButton_1 = new JButton("SALIR"); btnNewButton_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.exit(0); } }); btnNewButton_1.setBounds(304, 193, 89, 23); contentPane.add(btnNewButton_1); JButton btnNewButton_2 = new JButton("TOTAL"); btnNewButton_2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int a,b,c,d,f; a=Integer.parseInt(centro.getText()); b=Integer.parseInt(creo.getText()); c=Integer.parseInt(blanco.getText()); d=Integer.parseInt(nulo.getText()); f=a+b+c+d; t.setText(String.valueOf(f)); } }); btnNewButton_2.setBounds(17, 224, 89, 23); contentPane.add(btnNewButton_2); } }