• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Initialize table with array of objects

 
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
 
Marshal
Posts: 25832
69
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
Marshal
Posts: 25832
69
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
Marshal
Posts: 25832
69
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
Marshal
Posts: 25832
69
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
Marshal
Posts: 25832
69
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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
 
Esteban Calle
Greenhorn
Posts: 6
 
Rob Camick
Rancher
Posts: 3205
29
  • 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.
 
Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic