• Post Reply Bookmark Topic Watch Topic
  • New Topic

Initialization of Object [][] Array  RSS feed

 
Marcus Hathaway
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm having a null pointer exception error when trying to create a JTable. I think this is because the 2-dimensional array i'm passing in to the constructor has not been propery initialized.

I won't go into loads of detail here...but is there anything wrong with trying to do something like this:

private Object[][] tableData;
private JTable table;

public Object[][] getTableData()
{
tableData = String2DimensionalArray;
return tableData;
}

public JPanel getResultsPanel
{
//Set up panel stuff
table = new JTable(getTableData(), getColumnData());
//Obviously column data array been set up before
//Return panel
}


Notes from above - "String2DimensionalArray" is exactly what it says. The reason i'm doing it this way is because i'm using RMI to pull from a database. I know for certain the "String2DimensionalArray" is working fine.

Any comments would be greatly appreciated on this.....its something i've been trying to get right for ages. Thanks to people on this board i'm getting closer...but seem to be coming up against a brick wall again!
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write some code to print out the data returned from the getTableData() and getColumnData() methods.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!