• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Initialize table with array of objects

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 3324
32
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And what is a "cycle for"?

Edit: did you mean a "for loop"?
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
More cross posts
http://www.java-forums.org/awt-swing/47510-initialize-table-array-objects.html
http://www.dreamincode.net/forums/topic/243122-initialize-table-with-array-of-objects/
 
Esteban Calle
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Darryl Burke wrote:More cross posts
http://www.java-forums.org/awt-swing/47510-initialize-table-array-objects.html
http://www.dreamincode.net/forums/topic/243122-initialize-table-with-array-of-objects/



Sorry. i won't do again
 
Rob Camick
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Life just hasn't been the same since the volcano erupted and now the air is full of tiny ads.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic