Ver Mensaje Individual
  #11 (permalink)  
Antiguo 21/04/2013, 14:29
ambigus
 
Fecha de Ingreso: septiembre-2008
Mensajes: 221
Antigüedad: 15 años, 7 meses
Puntos: 1
Respuesta: ¿Cómo hacer funcionar dos JTable?

Si claro :) Aquí está ;)

Código Javascript:
Ver original
  1. if(!(this.txtCodigodocente.getText().trim().isEmpty()))
  2.         {
  3.            
  4.             Docente d = buscarMateriasdocente(this.txtCodigomateria.getText().trim());
  5.             if(d!=null){
  6.                 JOptionPane.showMessageDialog(this,
  7.                 "La Materia ya ha sido ingresada para el docente",
  8.                 "Agregar Materias a un Docente", JOptionPane.ERROR_MESSAGE);
  9.              }
  10.            
  11.            Materia m = buscarMateria(this.txtCodigomateria.getText().trim());
  12.             if(m==null){
  13.                 JOptionPane.showMessageDialog(this,
  14.                 "La Materia no se encuentra registrada en la Universidad",
  15.                 "Agregar Materias a un Docente", JOptionPane.ERROR_MESSAGE);
  16.                 this.txtCodigomateria.setText(null);
  17.                 this.txtCodigomateria.requestFocus();
  18.              }
  19.            
  20.             else{
  21.                
  22.                 for ( Docente docente : docentes )
  23.                 {
  24.                     if ( docente.getNombredocente().equalsIgnoreCase(this.txtNombredocente.getText().trim()))
  25.                     {    
  26.                               for(Materia materia : materias)
  27.                                  {
  28.                                      
  29.  
  30.                                     if ( materia.getCodigomateria().equalsIgnoreCase(this.txtCodigomateria.getText().trim()))
  31.                                       {
  32.                                         this.txtCodigomateria.setText(null);
  33.                                         this.txtCodigomateria.requestFocus();  
  34.                                         docente.setMateriadeldocente(materia.getCodigomateria());  
  35.                                         // Registrar datos en la tabla
  36.                                         model=(DefaultTableModel)this.jTable1.getModel();
  37.                                         Object fila[] = new Object[3];
  38.                                         fila[0] = materia.getCodigomateria();
  39.                                         fila[1] = materia.getNombremateria();
  40.                                         fila[2] = materia.getCreditos();
  41.                                         model.addRow(fila);
  42.  
  43.                                         jTable1.setModel(model);        
  44.                                       }
  45.                                       filas++;        
  46.                                    }    
  47.                            
  48.                      }
  49.    
  50.                 }      
  51.             }
  52.            
  53.            
  54.                  
  55.                  
  56.           }