Java

Moderators: zibadian
Number of threads: 7836
Number of posts: 18235

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Add a row to a JTable Posted by jakewendt on 20 Nov 2002 at 12:16 PM

Is there any way to add a row to a JTable at Runtime? I see that there is an addColumn and a columnAdded method, but nothing for Rows.

Anybody got any ideas? I basically just need a multi field list to hold a list of variables and there values.

TIA
Jake
Report
Re: Add a row to a JTable Posted by bashiro on 20 Nov 2002 at 1:43 PM
Are you talking of how to add records data to the table ?
I am asking this because when you add a record into a
table with columns a row is automaticallt generated to
add the recods.

Or did I misunderstood ?

bashiro


:
: Is there any way to add a row to a JTable at Runtime? I see that there is an addColumn and a columnAdded method, but nothing for Rows.
:
: Anybody got any ideas? I basically just need a multi field list to hold a list of variables and there values.
:
: TIA
: Jake
:

Report
Re: Add a row to a JTable Posted by jakewendt on 20 Nov 2002 at 4:53 PM

What I mean is that if you've got a table, like the one below ...

http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/SimpleTableDemo.java

...and I want to add another person to the list. I suppose you could equate it to adding another record to a database. With JList or JComboBox you can use .addItem or something, but I can't find anything equivalent for a JTable.



: Are you talking of how to add records data to the table ?
: I am asking this because when you add a record into a
: table with columns a row is automaticallt generated to
: add the recods.
:
: Or did I misunderstood ?
:
: bashiro
:
:
: :
: : Is there any way to add a row to a JTable at Runtime? I see that there is an addColumn and a columnAdded method, but nothing for Rows.
: :
: : Anybody got any ideas? I basically just need a multi field list to hold a list of variables and there values.
: :
: : TIA
: : Jake
: :
:
:

Report
Re: Add a row to a JTable Posted by bashiro on 21 Nov 2002 at 1:58 PM

What you can do is to create an instance of a Vector, HashTable or
HashMap and then get user inputs and store it in one of the above.
Later you populate JTable with the values.
You can also get the user input and add it to the array. In this case
you have to create (example a text file) and write to it for storage.
Example ;
Vector table = new Vector();
or 
HashMap hm = new HashMap();




The best way is to use a pure database sofware like Oracle, Ms Sql, Mysql (this is free), ms Access and many more. In this case you edit your tabel and let the DAtabase program take care of the storage (of course you have to use sql commands).

For the mean time take a look at suns Insertion of row example:
http://java.sun.com/docs/books/tutorial/jdbc/jdbc2dot0/sample.html


Hope this helps

Bashiro





:
: What I mean is that if you've got a table, like the one below ...
:
: http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/SimpleTableDemo.java
:
: ...and I want to add another person to the list. I suppose you could equate it to adding another record to a database. With JList or JComboBox you can use .addItem or something, but I can't find anything equivalent for a JTable.
:
:
:
: : Are you talking of how to add records data to the table ?
: : I am asking this because when you add a record into a
: : table with columns a row is automaticallt generated to
: : add the recods.
: :
: : Or did I misunderstood ?
: :
: : bashiro
: :
: :
: : :
: : : Is there any way to add a row to a JTable at Runtime? I see that there is an addColumn and a columnAdded method, but nothing for Rows.
: : :
: : : Anybody got any ideas? I basically just need a multi field list to hold a list of variables and there values.
: : :
: : : TIA
: : : Jake
: : :
: :
: :
:
:

Report
Re: Add a row to a JTable Posted by jabdulius on 26 Nov 2010 at 2:09 AM
I'm experiencing a similar problem and could really use some help. I've created a jTable in NetBeans 6.9.1, bound it to a MySQL table and a the elements to a list. When I update the list, however, the table is not updated.

I've verified that in the persistence.xml, an entity class is created and included for the table in question.

What am I doing wrong? Any thoughts or suggestions would be very much appreciated.

Thanks!



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.