Ver Mensaje Individual
  #16 (permalink)  
Antiguo 15/07/2010, 01:48
ioel10
 
Fecha de Ingreso: julio-2010
Mensajes: 104
Antigüedad: 13 años, 9 meses
Puntos: 2
Respuesta: me falla rellenar jTable de una manera, y de otra funciona...

Me he hecho una miniAplicación parecida a la tuya:

1. FrameView: sólo tiene un boton que llama a JDialog "padre".

Cita:
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
JFrame mainFrame = DesktopApplication1.getApplication().getMainFrame( );

d1 d1 = new d1(mainFrame, true);

d1.setLocationRelativeTo(mainFrame);

DesktopApplication1.getApplication().show(d1);

}
2. JDialog padre(d1): JTable y botón que llama a JDialog hijo(d2):

Cita:
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {

modelo = (DefaultTableModel) jTable1.getModel();

d2 d2 = new d2(this, true);

d2.setLocationRelativeTo(this);

DesktopApplication1.getApplication().show(d2);

ArrayList<Integer> listaD1 = d2.getLista();

for (int i = 0; i < listaD1.size(); i++) {

Object[] fila = new Object[1];

fila[0] = listaD1.get(i);

modelo.addRow(fila);

}
jTable1.setModel(modelo);

}
3. JDialog hijo(d2): Creo un arrayList y le inserto datos y a ese array le genero el método get que es al que llamaré desde JDialog padre(d1).

Cita:
private ArrayList<Integer> lista = new ArrayList<Integer>();

public d2(JDialog parent, boolean modal) {

super(parent, modal);

initComponents();

for (int j = 0; j < 5; j++) {
lista.add(j);
}
dispose();

}

public ArrayList<Integer> getLista() {
return lista;
}
Esto a mi me funciona y creo que es lo que haces tú pero con la diferencia de que ahorras el get. Lo de repintar ni te lo mires, yo aquí no lo hago.