NetBeans: Jtable

Hello,

I'm in from the C# world, and I'm trying to get this project done as quickly as possible.

So, a few questions, which haven't been answered from Google to my satisfaction:

How do I use a JTable? How do I add columns? How do I add rows?

If I have a jTable created via NetBeans, how do I update it with new information? In C#, I'd swap the datasource, and call refresh() but I cannot find anything like that here.

Additionally, how do I access a given row in a jTable?

And is a Jtable just a UI component, or can I use it to store data anywhere? If not, what else can I use?

The clock is ticking for me, so the sooner this is answered, the better.

Thanks,
Ryan

rossryanAsked:
Who is Participating?
 
objectsCommented:
nothing built in, you'll need to handle it yourself by looping thru the rows and adding to your Document according to its schema
0
 
objectsCommented:
so many questions :)

> How do I add columns?

http://www.exampledepot.com/egs/javax.swing.table/AppendCol.html

>  How do I add rows?

Add it to the model, for example when DefaultTableModel has an addRow() method

> how do I update it with new information?

use setModel() to change the data model

> Additionally, how do I access a given row in a jTable?

thru the model

> And is a Jtable just a UI component, or can I use it to store data anywhere? If not, what else can I use?

It is just a UI component, the data is actualled stored in the TreeModel which you can use elsewhere

good background reading:

http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
0
 
rossryanAuthor Commented:
Right, how do I grab the tree?
0
 
objectsCommented:
>  the data is actualled stored in the TreeModel which you can use elsewhere

sorry, that should have said TableModel (not TreeModel)

you can get the model from the table

TableModel model = table.getModel();

or keep a reference to it when you initially create it
0
 
rossryanAuthor Commented:
Right, at this point, I am looking to shove the model into an xml file. Any tips for making that happen?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.