Java - Pasar una fecha de un JTable a un JDateChooser

 
Vista:
sin imagen de perfil
Val: 9
Ha aumentado 1 puesto en Java (en relación al último mes)
Gráfica de Java

Pasar una fecha de un JTable a un JDateChooser

Publicado por marc (29 intervenciones) el 12/03/2014 20:14:33
Hola amigos tengo una duda yo recibo en un jtable datos de una tabla sql server con formato fecha y hora, pero deseo que al hacer clic sobre el registro deseado me muestre esa fecha en el jdatechooser con el formato dd/MM/yyyy

Gracias por su ayuda de antemano

Este es el código que uso, en última instancia mandé el valor del fecha a un txtField

private void tbCKMouseClicked(java.awt.event.MouseEvent evt) {
//Ubicar los campos de la tabla en su respectivo control con un clic
if(tbCK.getSelectedRow()>=0)
{
String[] datosLeidos=
{
String.valueOf(tbCK.getValueAt(tbCK.getSelectedRow(), 0)),
String.valueOf(tbCK.getValueAt(tbCK.getSelectedRow(), 1)),
String.valueOf(tbCK.getValueAt(tbCK.getSelectedRow(), 2)),
String.valueOf(tbCK.getValueAt(tbCK.getSelectedRow(), 3)),
String.valueOf(tbCK.getValueAt(tbCK.getSelectedRow(), 4)),
String.valueOf(tbCK.getValueAt(tbCK.getSelectedRow(), 5)),
String.valueOf(tbCK.getValueAt(tbCK.getSelectedRow(), 6)),
String.valueOf(tbCK.getValueAt(tbCK.getSelectedRow(), 7)),
String.valueOf(tbCK.getValueAt(tbCK.getSelectedRow(), 8)),
String.valueOf(tbCK.getValueAt(tbCK.getSelectedRow(), 9)),
String.valueOf(tbCK.getValueAt(tbCK.getSelectedRow(), 10))
};
limpiaCamposCK();
txtCodMov.setText(datosLeidos[0]);
txtTipoMov.setText(datosLeidos[1]);
txtEmpresa.setText(datosLeidos[2]);
txtBanco.setText(datosLeidos[3]);
txtCuenta.setText(datosLeidos[4]);
txtNumCK.setText(datosLeidos[5]);
txtConcepto.setText(datosLeidos[6]);
txtPrueba.setText(datosLeidos[7]);

//Enviando la fecha al JDateChooser
String f=txtPrueba.getText();
SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy");
Date fecha=null;
try
{
fecha=formato.parse(f, null);
}
catch (Exception e)
{
JOptionPane.showMessageDialog(null, e);
}
dateFecha.setDate(fecha);


txtMonto.setText(datosLeidos[8]);
txtBeneficiario.setText(datosLeidos[9]);
ckbEstado.setText(datosLeidos[10]);
botonesActivosCK(true,true,true,false,false,true);
camposActivosCK(true,true,true,true,true,true,true,true,true,true,true);
}
else
{
JOptionPane.showMessageDialog(this, "Debe seleccionar un registro");
}
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Pasar una fecha de un JTable a un JDateChooser

Publicado por William (1 intervención) el 04/12/2015 01:08:13
Hola amigo, tengo el mismo problema que tu, me preguntaba si pudiste resolverlo
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar