2 Replies - 1080 Views - Last Post: 11 August 2011 - 06:06 PM Rate Topic: -----

#1 ebing   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 23-September 10

Initialize table with array of objects

Posted 11 August 2011 - 07:47 AM

Good mornigns
I have a problem to initialize the jtable from a FOR with BD or an array.

My problem is the example tableFilterDemo.java, I need the funcionality of this,
but when i want load data of my BD or an arraylist i have the problem.

I need load the array of objects with a FOR getting all the lines of file or rows of table

private Object[][] data = {
{ "Mary", "Campione", "Snowboarding"},
{ "John", "guifru", "skyiin"},};


Greetings

Is This A Good Question/Topic? 0
  • +

Replies To: Initialize table with array of objects

#2 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12772
  • View blog
  • Posts: 45,965
  • Joined: 27-December 08

Re: Initialize table with array of objects

Posted 11 August 2011 - 07:48 AM

You should look at creating a DefaultTableModel object to populate the data into, then pass that to the JTable.
Was This Post Helpful? 0
  • +
  • -

#3 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Initialize table with array of objects

Posted 11 August 2011 - 06:06 PM

The JTable class has a constructor that expect an Object[][] as parameter with an Object[] for the columns header. No need to use a for(;;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1