Recorrer un Array bidimencional a travez de un jTable
--------Codigo del public class recorrer extends javax.swing.JFrame {---------------
DefaultTableModel tabla= new DefaultTableModel();
int[][] array= new int [4][4];
----------------------------------Codigo del Unit Component--------------------------------
tabla.addColumn("a");
tabla.addColumn("b");
tabla.addColumn("c");
tabla.addColumn("d");
------------------------------Código del botón (Recorrer el array)--------------------------
for(int i=0; i<4;i++){
for(int j=0; j<4;j++){
array[i][j]=Integer.parseInt(JOptionPane.showInputDialog("ingrese"));
arra[j]=array[i][j];
}
tabla.addRow(arra);
}
jTable1.setModel(tabla);
Comentarios
Publicar un comentario