Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Crea JTable

  Asked By: Karina    Date: Jan 11    Category: Java    Views: 745
  

I have this lineas... I need create a table. I have datas stored in
a vector of objects instance: nemonicos: each object include : a
number line, a name, descripcion y a vector of parameter.
ex:
N00 G00 X0 Z0 F0
N02 M30
N00 number line
X,Y,Z are parameter
G00 is name

the method

JOptionPane optionPane = new JOptionPane();
ModeloTabla tablaModeloInicial = new ModeloTabla();
tab_result.setModel(tablaModeloInicial);

try{


int filas = revisorCNC.Control.Revisora.numeroLineas;

String[] columnas = new String
[revisorCNC.Control.Revisora.numeroColumnas];

//Carga los nombres de las columnas de la tabla
for (int i = 0; i <
revisorCNC.Control.Revisora.numeroColumnas; i++){
columnas[i] =
revisorCNC.Control.Revisora.nombre_colum[i];
}

Object[][] datos= new Object[filas]
[revisorCNC.Control.Revisora.numeroColumnas];

int i=0; int j = 0;
for(i =0; i< filas; i++){
Nemonico objeto = new Nemonico();
objeto = (Nemonico)
revisorCNC.Control.Revisora.nemonicos.elementAt(j);

/* datos[i][j] = new String("");
datos[i][j] = (String)objeto.getNumeroLinea();
System.out.println((String)objeto.getNumeroLinea());
j++;*/


for( j =0; j <
revisorCNC.Control.Revisora.numeroColumnas ; j++){
if(i <= revisorCNC.Control.Revisora.nemonicos.size
()){

datos[i][j] = new String("");
datos[i][j] = (String)objeto.getNombre();


//Recorre el vector del objeto nemonico :
Parametros
int pos = 0;
for(pos = 0; pos < objeto.getParametros
().size(); pos++){
j++;//inc columna
datos[i][j] = new String("");
datos[i][j] =(String)objeto.getParametros
().elementAt(pos).toString();



}//Fin for Parametros

}//Fin if(i<= nemonicos.size()

} //Fin while columnas



}//Fin for Filas
//Construir la tabla
ModeloTabla tablaModelo = new ModeloTabla
(columnas,datos);
tab_result.setModel( tablaModelo );

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Crea JTable Or get search suggestion and latest updates.




Tagged: