Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Initialize table with array of objects

 
Esteban Calle
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Clapham
Sheriff
Pie
Posts: 20769
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you tell us what "FOR" and "BD" mean in your post?
 
Esteban Calle
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Can you tell us what "FOR" and "BD" mean in your post?



BD database and for is the cycle for
 
Paul Clapham
Sheriff
Pie
Posts: 20769
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what is a "cycle for"?

Edit: did you mean a "for loop"?
 
Paul Clapham
Sheriff
Pie
Posts: 20769
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I think I might understand what your question is.

You aren't asking how to initialize a JTable from an array of arrays, you already know how to do that. You are asking how to produce an array of arrays from data which is in a database.

Am I right?
 
Esteban Calle
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Okay, I think I might understand what your question is.

You aren't asking how to initialize a JTable from an array of arrays, you already know how to do that. You are asking how to produce an array of arrays from data which is in a database.

Am I right?


at last someone understands me. YES it is my problem. loop for yes
 
Paul Clapham
Sheriff
Pie
Posts: 20769
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay. Your question is nothing to do with initializing the table from an array, it is all about creating that array. So using the title "Initialize table with array of objects" was very misleading and that is why nobody understands it.

Now I am going to make another guess. You cannot put the data from your database into an array, because you don't know how big the array should be. Is that right?
 
Esteban Calle
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Okay. Your question is nothing to do with initializing the table from an array, it is all about creating that array. So using the title "Initialize table with array of objects" was very misleading and that is why nobody understands it.

Now I am going to make another guess. You cannot put the data from your database into an array, because you don't know how big the array should be. Is that right?


yes it is correct, which would be the post title?
 
Paul Clapham
Sheriff
Pie
Posts: 20769
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then don't use an array of arrays. It's also possible to initialize a JTable with a Vector of Vectors.

Make a Vector for each row you get from the database, add each column to that Vector as an entry.

Then add each row Vector to a main Vector which represents the whole table.
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
 
Esteban Calle
Greenhorn
Posts: 6
 
Rob Camick
Ranch Hand
Posts: 2542
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
at last someone understands me. YES it is my problem. loop for yes


Excuse me, you where given the answer to your question hours ago (in one of your many cross postings), if you would take the time to read your answers.

You don't understand how a TableModel works and the answer was to forget about Arrays because they are NOT dynamic.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic