Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to pass an 2D array to jtable in Netbeans
    text
    copied!<p>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?</p> <pre><code>jTable1 = new javax.swing.JTable(); jTable1.setModel(new javax.swing.table.DefaultTableModel( new int[][] = TableAdapter.getTableC() )); jScrollPane1.setViewportView(jTable1); </code></pre> <p>It keeps saying arraydimension missing, then I call the method getDimension() and I inserted it in various ways </p> <pre><code>new int[getDimension()][] = TableAdapter.getTableC() </code></pre> <p>or</p> <pre><code>new int[getDimension()][new int[getDimension()][] = TableAdapter.getTableC() </code></pre> <p>Thanks in adavance, and I am using Netbeans.</p> <hr> <p>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</p> <pre><code>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&lt;dimension;i++){ for(int j=0;j&lt;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; } } </code></pre> <hr> <p>also when I use</p> <pre><code>jTable1.setModel(new javax.swing.table.DefaultTableModel( TableAdapter.getTableC() )); </code></pre> <p>it has these errors: <img src="https://i.stack.imgur.com/MPxZZ.png" alt="]![Error">(C:\Users\user\Desktop\error.png)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload