Foros del Web » Programación para mayores de 30 ;) » Java »

agregar variables a columnas de jtable

Estas en el tema de agregar variables a columnas de jtable en el foro de Java en Foros del Web. Columna 0 que es VENDEDOR es String, Efectivo es Double , EC es double, y Dato es integer @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código Java: Ver original String ...
  #1 (permalink)  
Antiguo 04/03/2017, 07:47
Avatar de soy_nicanor  
Fecha de Ingreso: mayo-2010
Mensajes: 374
Antigüedad: 13 años, 11 meses
Puntos: 3
agregar variables a columnas de jtable

Columna 0 que es VENDEDOR es String, Efectivo es Double , EC es double, y Dato es integer
Código Java:
Ver original
  1. String[] titulos = {"Vendedor","Efectivo ", "Efectivo Cja", "Dato"};
  2.         String[] registro = new String[4];
  3.         modelo = new DefaultTableModel(null, titulos);
  4.  
  5.         Connection cn = Conexion.getConnection();
  6.  
  7.         String sSQL = "SELECT usuario.usuario, reportediario.gananciaTotal, reportediario.efectivoBruto "+
  8.                 "FROM reportediario " +
  9.                 "INNER JOIN usuario ON usuario.id_us=reportediario.id_us ";                
  10.         try
  11.         {
  12.             Statement st = cn.createStatement();
  13.             ResultSet rs = st.executeQuery(sSQL);
  14.             int i=0;
  15.             while(rs.next())
  16.             {
  17.                 registro[0] = rs.getString("usuario.usuario");
  18.                 registro[1] = rs.getString("reportediario.gananciaTotal");
  19.                 registro[2] = rs.getString("reportediario.efectivoBruto");
  20.                 registro[3] = String.valueOf(i);
  21.                 i++;
  22.                 modelo.addRow(registro);              
  23.             }            
  24.             jTable1.setModel(modelo);//Buscador Princiapal          
  25.  
  26.             modelo = new DefaultTableModel(null, titulos) {
  27.                     public Class getColumnClass(int column) {
  28.                       if (column >= 0 && column <= getColumnCount())
  29.                         return getValueAt(0, column).getClass();
  30.                       else
  31.                         return Object.class;
  32.                     }
  33.                 };
  34.         }
  35.         catch (SQLException ex){
  36.             JOptionPane.showMessageDialog(null, ex);
  37.         }
  38.  
  39.         TableRowSorter<TableModel> elQueOrdena = new TableRowSorter<TableModel>(modelo);      
  40.         jTable1.setRowSorter(elQueOrdena);
Como podría agregar variables a las columnas.
__________________
Muy Feliz
  #2 (permalink)  
Antiguo 04/04/2017, 09:59
Avatar de Fuzzylog  
Fecha de Ingreso: agosto-2008
Ubicación: En internet
Mensajes: 2.511
Antigüedad: 15 años, 7 meses
Puntos: 188
Respuesta: agregar variables a columnas de jtable

¿Podrías explicar qué es lo que necesitas un poco mejor?
__________________
if (fuzzy && smooth) {
fuzzylog = "c00l";
return true;
}

Etiquetas: buscador, columnas, jtable, set, string, variables
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 01:59.