Tema: jtable ??
Ver Mensaje Individual
  #5 (permalink)  
Antiguo 21/09/2012, 14:46
Horyni3
 
Fecha de Ingreso: septiembre-2012
Mensajes: 1
Antigüedad: 11 años, 7 meses
Puntos: 1
Información Respuesta: jtable ??

Hola

Código Javascript:
Ver original
  1. DefaultTableModel Model;
  2.     String   fila[];
  3.     private  void  titulosTabla()
  4.     {
  5.         String  vFecha[]= {"2003","2004","2005","2006","2007","2008","2009","2010","2011","2012"};
  6.         Model= new DefaultTableModel(null,vFecha);
  7.         this.tblTabla.setModel(Model);
  8.     }
  9.  
  10.     private void filas()
  11.     {
  12.         fila= new String[5];
  13.         for(int i=0;i<fila.length;i++)
  14.         {
  15.             Model.addRow(fila);
  16.         }
  17.     }
  18.     public JTable()
  19.     {
  20.         initComponents();
  21.         titulosTabla();
  22.         filas();
  23.     }
  24.  private void btnProcesarActionPerformed(java.awt.event.ActionEvent evt) {                                            
  25.         // TODO add your handling code here:
  26.         int  c=0;
  27.         String valor;
  28.         valor=txtCantidad.getText();
  29.  
  30.         Model=(DefaultTableModel) this.tblTabla.getModel();
  31.         switch(Integer.parseInt(txtAño.getText()))
  32.         {
  33.             case 2003: c=0; break;case 2004: c=1; break;case 2005: c=2; break;case 2006: c=3; break;case 2007: c=4; break;
  34.             case 2008: c=5; break;case 2009: c=6; break;case 2010: c=7; break;case 2011: c=8; break;case 2012: c=9; break;
  35.         }
  36.         for(int i=0; i<this.tblTabla.getRowCount();i++)
  37.         {
  38.             if(fila[i]==null)
  39.             {
  40.                 Model.setValueAt(valor, i, c);
  41.                 break;
  42.             }
  43.         }
  44.        
  45.        
  46.     }
Salu2