Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
NOMBRE DE LA PRCTICA:
Interfaces graficas
NOMBRE DE LA UNIDAD DE APRENDIZAJE:
FACILITADOR:
ING. LETICIA JAEL ROJAS ORTIZ
INTEGRANTES:
No
1
Matrcula
1417INI1
10
Nombre
DORIS SNCHEZ TORRES
MARZO, 2016
Nmero
de
Prctica:
Laboratori
o de:
Resultado
de
Aprendiza
je:
Justificaci
n:
Duracin (horas)
Marco
Terico:
COMPUTACION
Al concluir la unidad de aprendizaje el alumno ser capaz de
conocer las principales caractersticas de Java y las diferentes
interfaces que pueden ser utilizadas en dicho lenguaje, as mismo
emplearlas para desarrollar aplicaciones.
Conocer las principales caractersticas de Java
Conocer las principales caractersticas de interfaces de
Java
Utilizar y aplicar las distintas interfaces dentro del
desarrollo de aplicaciones Java
Emplear Interfaces grficas.
Material,
equipo y/o
reactivos:
Desarrollo
de la
Prctica:
-MOSTRAR DATOS
INGRESAR DATOS:
MODIFICAR:
ELIMINAR:
CODIGO:
package PuntodeVenta;
import
import
import
import
import
java.sql.Connection;
java.sql.SQLException;
java.sql.Statement;
java.text.SimpleDateFormat;
javax.swing.JOptionPane;
/**
*
* @author Doris
*/
public class Alta_usr extends javax.swing.JFrame {
String nombre="";
String apellpat="";
String apellmat="";
String sexo="";
String edo="";
String educacion="";
String fecha="";
Boolean compu=false;
Boolean art=false;
Boolean deporte=false;
Boolean mus=false;
getContentPane().add(txt_apemat, new
org.netbeans.lib.awtextra.AbsoluteConstraints(340, 120, 220, 30));
radio_m.setBackground(new java.awt.Color(204, 204, 204));
buttonGroup1.add(radio_m);
radio_m.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14)); // NOI18N
radio_m.setForeground(new java.awt.Color(255, 255, 255));
radio_m.setText("M");
radio_m.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
radio_mActionPerformed(evt);
}
});
getContentPane().add(radio_m, new
org.netbeans.lib.awtextra.AbsoluteConstraints(100, 190, -1, -1));
buttonGroup1.add(radio_f);
radio_f.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14)); // NOI18N
radio_f.setForeground(new java.awt.Color(255, 255, 255));
radio_f.setText("F");
radio_f.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
radio_fActionPerformed(evt);
}
});
getContentPane().add(radio_f, new
org.netbeans.lib.awtextra.AbsoluteConstraints(170, 190, -1, -1));
buttonGroup2.add(radio_sol);
radio_sol.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14)); // NOI18N
radio_sol.setForeground(new java.awt.Color(255, 255, 255));
radio_sol.setText("Soltero");
radio_sol.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
radio_solActionPerformed(evt);
}
});
getContentPane().add(radio_sol, new
org.netbeans.lib.awtextra.AbsoluteConstraints(140, 260, -1, -1));
buttonGroup2.add(radio_cas);
radio_cas.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14)); // NOI18N
radio_cas.setForeground(new java.awt.Color(255, 255, 255));
radio_cas.setText("Cassdo");
getContentPane().add(radio_cas, new
org.netbeans.lib.awtextra.AbsoluteConstraints(240, 260, -1, -1));
buttonGroup2.add(radio_div);
radio_div.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14)); // NOI18N
radio_div.setForeground(new java.awt.Color(255, 255, 255));
radio_div.setText("Divorciado");
radio_div.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
radio_divActionPerformed(evt);
}
});
getContentPane().add(radio_div, new
org.netbeans.lib.awtextra.AbsoluteConstraints(330, 260, -1, -1));
Musica.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14)); // NOI18N
Musica.setForeground(new java.awt.Color(255, 255, 255));
Musica.setText("Musica");
Musica.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MusicaActionPerformed(evt);
}
});
getContentPane().add(Musica, new
org.netbeans.lib.awtextra.AbsoluteConstraints(300, 450, -1, -1));
Deportes.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14)); // NOI18N
Deportes.setForeground(new java.awt.Color(255, 255, 255));
Deportes.setText("Deportes");
Deportes.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DeportesActionPerformed(evt);
}
});
getContentPane().add(Deportes, new
org.netbeans.lib.awtextra.AbsoluteConstraints(160, 440, -1, -1));
computacion.setBackground(new java.awt.Color(255, 255, 255));
computacion.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14)); //
NOI18N
computacion.setForeground(new java.awt.Color(255, 255, 255));
computacion.setText("Computacion");
computacion.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
computacionActionPerformed(evt);
}
});
getContentPane().add(computacion, new
org.netbeans.lib.awtextra.AbsoluteConstraints(160, 400, -1, -1));
Artes.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14)); // NOI18N
Artes.setForeground(new java.awt.Color(255, 255, 255));
Artes.setText("Arte");
Artes.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ArtesActionPerformed(evt);
}
});
getContentPane().add(Artes, new
org.netbeans.lib.awtextra.AbsoluteConstraints(300, 400, -1, -1));
Educacion.setModel(new javax.swing.DefaultComboBoxModel(new String[]
{ "primaria", "secundaria", "preperatoria", "universidaad" }));
getContentPane().add(Educacion, new
org.netbeans.lib.awtextra.AbsoluteConstraints(140, 320, 280, 30));
DateChooser.setDateFormatString("yyyy-MM-dd");
getContentPane().add(DateChooser, new
org.netbeans.lib.awtextra.AbsoluteConstraints(570, 270, 140, 20));
jButton1.setText("Eliminar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(660, 150, 90, 30));
jButton2.setText("Modificar");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
getContentPane().add(jButton2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(660, 193, 90, 30));
jPanel1.setBackground(new java.awt.Color(255, 153, 153));
getContentPane().add(jPanel1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(10, 0, 820, 500));
pack();
}// </editor-fold>
private void txt_nombreActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void txt_apepatActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void txt_apematActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void radio_mActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void radio_fActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void radio_divActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void MusicaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void DeportesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void computacionActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void ArtesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void GuardarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
conexion= new ConexionDB();
Connection con=conexion.GetConnection();
Statement st;
nombre=txt_nombre.getText();
apellpat=txt_apepat.getText();
apellmat=txt_apemat.getText();
fecha = new
SimpleDateFormat("yyyy/MM/dd").format(DateChooser.getDate());
if (radio_m.isSelected()==true){
sexo="M";
}else if (radio_f.isSelected()==true){
sexo="F";
}
if (radio_sol.isSelected()==true){
edo="soltero";
}else if (radio_cas.isSelected()==true){
edo="casado";
}else if (radio_div.isSelected()==true){
edo="divorsiado";
}
educacion=(String)Educacion.getSelectedItem();
//
compu=computacion.isSelected();
deporte=Deportes.isSelected();
art=Artes.isSelected();
mus=Musica.isSelected();
// System.out.println(nombre +"\n"+
apellpat+"\n"+apellmat+"\n"+sexo+"\n"+edo+"\n"+educacion+"\n"+compu+"\
n"+deporte+"\n"+art+"\n"+mus+"\n"+fecha);
String sql="Insert into tbl_cliente
(nombre_cl,apepat_cl,apemat_cl,sexo_cl,edo_cl,educacion_cl,computacion_cl,de
portes_cl,arte_cl,musica_cl,Fecha)"
+"
values('"+nombre+"','"+apellpat+"','"+apellmat+"','"+sexo+"','"+edo+"','"+ed
ucacion+"',"+compu+","+deporte+","+art+","+mus+",'"+fecha+"')";
try{
st=con.createStatement();
st.executeUpdate(sql);
con.close();
st.close();
JOptionPane.showMessageDialog(null,"INSERTEADO CON EXITO");
}catch(SQLException e){
e.printStackTrace();
}
}
private void radio_solActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void ConsultarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
ConsultaDatos_1 ventana = new ConsultaDatos_1();
ventana.setVisible(true);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
java.util.logging.Logger.getLogger(Alta_usr.class.getName()).log(java.util.logging
.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Alta_usr.class.getName()).log(java.util.logging
.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Alta_usr.class.getName()).log(java.util.logging
.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Alta_usr().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JCheckBox Artes;
private javax.swing.JButton Consultar;
private com.toedter.calendar.JDateChooser DateChooser;
private javax.swing.JCheckBox Deportes;
private javax.swing.JComboBox Educacion;
private javax.swing.JButton Guardar;
private javax.swing.JCheckBox Musica;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.ButtonGroup buttonGroup2;
private javax.swing.JCheckBox computacion;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel1;
private javax.swing.JRadioButton radio_cas;
private javax.swing.JRadioButton radio_div;
private javax.swing.JRadioButton radio_f;
private javax.swing.JRadioButton radio_m;
private javax.swing.JRadioButton radio_sol;
private javax.swing.JTextField txt_apemat;
private javax.swing.JTextField txt_apepat;
public javax.swing.JTextField txt_nombre;
conexion=DriverManager.getConnection(servidor,usuarioDB,passwordDB);
}
catch (ClassNotFoundException ex){
JOptionPane.showMessageDialog(null, ex,"error en el driver",
JOptionPane.ERROR_MESSAGE);
conexion=null;
}
catch(SQLException ex){
JOptionPane.showMessageDialog(null, ex, "error en la conexion de
BD",JOptionPane.ERROR_MESSAGE);
conexion=null;
}catch(Exception ex){
JOptionPane.showMessageDialog(null,
ex,"error3",JOptionPane.ERROR_MESSAGE);
conexion=null;
}finally{
return conexion;
}
}
package PuntodeVenta;
import PuntodeVenta.ConexionDB;
import java.awt.event.MouseAdapter;
import
import
import
import
import
import
import
import
import
java.awt.event.MouseEvent;
java.sql.Connection;
java.sql.ResultSet;
java.sql.Statement;
javax.swing.JOptionPane;
javax.swing.JScrollPane;
javax.swing.JTable;
javax.swing.ListSelectionModel;
javax.swing.table.DefaultTableModel;
/**
*
* @author Doris
*/
public class ConsultaDatos_1 extends javax.swing.JFrame {
DefaultTableModel dtmEjemplo;
ListSelectionModel lsmConsultaDatos_1;
JTable tblEjemplo;
JScrollPane scpEjemplo;
public ConsultaDatos_1() {
tblEjemplo = new JTable();
scpEjemplo= new JScrollPane();
//Llenamos el modelo
dtmEjemplo = new DefaultTableModel(null,getColumnas());
setFilas();
tblEjemplo.setModel(dtmEjemplo);
scpEjemplo.add(tblEjemplo);
this.add(scpEjemplo);
this.setSize(800, 200);
scpEjemplo.setViewportView(tblEjemplo);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
/********al dar clic pasar a cajas de texto**************/
tblEjemplo.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent e){
Alta_usr d= new Alta_usr();
//String id
=(String)tblEjemplo.getValueAt(tblEjemplo.getSelectedRow(),0);
//d.nombre.setText(id);
d.txt_nombre.setText("");
tblEjemplo.rowAtPoint(e.getPoint());
//d.txt_nombre.setText(tblEjemplo.getValueAt(row,0).toString);
}
});
}
//Encabezados de la tabla
private String[] getColumnas()/// agregar los campos que hacen falta
{
String columna[]=new String[]{"Nombre","Apellido Paterno", "Apellido
Materno","sexo","estado","educacion","compuacion","deportes","arets","musica
","fecha_nac","ID"};
return columna;
}
private void setFilas()
{
ConexionDB conexion= new ConexionDB();
// Ejm12_1_ConectarPostgreSQL cnndb = new
Ejm12_1_ConectarPostgreSQL();
// CachedRowSet crs = conexion.Function("SELECT deptno, dname, loc
FROM dept");
Connection con=conexion.GetConnection();
Statement
st;
ResultSet
rs;
String sql="SELECT * FROM tbl_cliente";/// verificar latabla como se llama
Object datos[]=new Object[12];
//Numero de columnas de la tabla
///crresponde al numero de columnas de la BD
try {
st=con.createStatement();
rs=st.executeQuery(sql);
while (rs.next()) {
for (int i = 0; i < 12; i++) {/// revisar el ciclo for para revisar los
fregiatros de os datos
datos[i] = rs.getObject(i + 1);
}
dtmEjemplo.addRow(datos);
}
rs.close();
} catch (Exception e) {
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
TABLA ","ERROR",JOptionPane.ERROR_MESSAGE);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code
(optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default
look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(ConsultaDatos.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ConsultaDatos.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ConsultaDatos.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ConsultaDatos.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ConsultaDatos_1().setVisible(true);
}
});
}
Resultado
sy
observaci
ones
Conclusio
nes y/o
recomend
aciones
Referenci
as
bibliogrfi
cas y/o
Fuentes
consultad
as
Manejo y
Disposici
n de
Desechos:
Grup
o:
INI5M
A
Equipo:
Calificaci
n: