LA APLICACIÓN DE LAS PROPIEDADES TEXTUALES A LOS TEXTOS.pdf
Taller java swing
1. 1
SAN JOSE
FUNDACION DE EDUCACION SUPERIOR
TALLER DE JAVA SWING
1. Cree una tabla en mysql, de nombre alumno(id_alumno,nombre,apellido,grado,sexo):todos los
capos de tipo varchar().
2. En el proyecto de las clases pasadas,haga lo siguiente.(Debe tener las clases Conexión.javay
Logica.java)
A. Cree un JInternalFrame y coloquelos objetos necesarios para ingresar losdatos dela tabla
alumno. Cree un botón llamado INGRESO otro llamado NUEVO.
B. En el botón INGRESO coloqueel siguiente código.Muestra l error sejava pideque coloqueel
código en un bloque try-catch
________________________________________________________________________
Logica conec= new Logica();
int rs=0;
String codigo=this.jTextField1.getText();
String nombre= this.jTextField2.getText();
String apellido=this.jTextField3.getText();
String grado=this.jTextField4.getText();
String sexo=this.jTextField5.getText();
String sql="insertinto
alumno(id_alumno,nombre,apellido,grado,sexo)values('"+codigo+"','"+nombre+"','"+apellido+"','"+
grado+"','"+sexo+"')";
rs=conec.InsertarGeneralSQL(sql);
if(rs==1)
{
JOptionPane.showMessageDialog(null,"El registro seinsertó con éxito");
this.jButton1.setEnabled(false);
}
else
{
JOptionPane.showMessageDialog(null,"Problemas al insertar el registro");
}
C. En el botón “nuevo” coloqueel siguientecódigo:
__________________________________________________________________________
this.jTextField1.setText(null);
this.jTextField2.setText(null);
this.jTextField3.setText(null);
this.jTextField4.setText(null);
this.jTextField5.setText(null);
this.jButton1.setEnabled(true);
__________________________________________________________________________
2. 2
D. Agregue el formulario al Frameprincipal(JDESTOK PANE), agregue un menú insertar .
3. Realicelos siguientes pasos:
A. Cree un JInternalFrame:
B. Coloque título “MOSTRAR RESULTADO DE CONSULTA”
C. Inserte un elemento TABLE.
D. INSERTE UN BOTON Y COLOQUE NOMBRE CONSULTAR.
E. En el botón consultar coloqueel siguientecódigo. Muestra error, java pideque coloqueel código
en un bloquetry-catch
____________________________________________________________________________
String [] columna={"IDENTIFICACION","NOMBRE","APELLIDOS","GRADO","SEXO"};
DefaultTableModel tabla = new DefaultTableModel(null,columna);
ResultSet rs=null;
Logica con = new Logica();
String sql="select* from alumno";
rs= con.ConsultaGeneralSQL(sql);
if(rs.next())
{
while(rs.next())
{
String id=rs.getString(1);
String nom=rs.getString(2);
String apel=rs.getString(3);
String grado=rs.getString(4);
String sex=rs.getString(5);
String [] filas={id,nom,apel,tel,grado,sex};
tabla.addRow(filas);
}
this.jTable1.setModel(tabla);
}
F. Agregue el formulario al Frameprincipal(JDESTOK PANE), en un menú consultar.
4. Haga los siguientes pasos.
A. Cree un JInternalFrame.
3. 3
B. Coloque título eliminar registros.
C. Coloque un RadioButton y coloqueel nombre de ESTUDIANTE.
D. Coloque un RadioButton y coloqueel nombre de USUARIOS.
E. Agregue un ButtonGroup.
F. De clic derecho al RadioButton1 y selecciones propiedades, en la propiedad ButtonGroup
selecciones ButtonGroup1 y la propiedad selected seleccione.
G. Repita lo mismo con el otro RadioButton, este si no se selecciona la propiedad selected.
H. Coloque un Label(código) y un TextField.
I. Coloque un botón ejecutar.
J. En el botón ejecutar coloque el siguientecódigo: Pidecolocar este código en un try-catch
Logica conec= new Logica();
int rs=0;
int rs1=0;
if(jRadioButton1.getModel().isSelected())
{
String codigo=this.jTextField1.getText();
String sql="delete from usuario where id=’"+codigo+"’";
try {
rs=conec.DeleteGeneralSQL(sql);
if(rs==1)
{
JOptionPane.showMessageDialog(null,"seha elimindo el regitro");
}
else
{
JOptionPane.showMessageDialog(null,"Problemas al eliminarel registro");
}
__________________________________________________________________________
K. Agregue el formulario al Frameprincipal(JDESTOK PANE), agregue un menú eliminar.
L. Implemente el código del RadioButton USUARIOS para eliminar usuariosdela basede datos.
5. PARA LOS ESTUDIANTES QUE DESEEN RECUPERAR UNA NOTA PERDIADA, REALIZAR EL EJERCICIO
DEL VIDEO. PRESENTAR Y SUSTENATR EN AL PROXIMA CLASE.
https://www.youtube.com/watch?v=thnv-Ku7pyg