It is my first time I create a jtable,I want to display a jtable of int from another class.So I call the method getTable and assign it to the jtable,is it right?
jTable1 = new javax.swing.JTable();
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new int[][] = TableAdapter.getTableC()
));
jScrollPane1.setViewportView(jTable1);
It keeps saying arraydimension missing, then I call the method getDimension() and I inserted it in various ways
new int[getDimension()][] = TableAdapter.getTableC()
or
new int[getDimension()][new int[getDimension()][] = TableAdapter.getTableC()
Thanks in adavance, and I am using Netbeans.
I get the an animal table which has two types of animals and from this I interpret to integer code which is stored in a new table(tableC) just to make it easier
package tigers.bunnies;
public class TableAdapter {
static public int tableC[][];//=new int[3][3];
static private int dimension;
public void Table(){
Animal tableT[][];
tableT = table.getTable();
dimension=tableT.length;
//int tableC[][];
tableC = new int[dimension][dimension];
for(int i=0;i<dimension;i++){
for(int j=0;j<dimension;j++){
if(tableT[i][j]==null){
tableC[i][j]=0000;
}
else if(tableT[i][j] instanceof tiger){
tableC[i][j]=0001;
}
else if(tableT[i][j] instanceof tiger){
tableC[i][j]=0002;
}
}
}
}
public static int[][] getTableC() {
return tableC;
}
public static int getDimension() {
return dimension;
}
}
also when I use
jTable1.setModel(new javax.swing.table.DefaultTableModel(
TableAdapter.getTableC()
));
it has these errors:
(C:\Users\user\Desktop\error.png)
new int[][] = TableAdapter.getTableC()