Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2004

Tip: Looking for answers? Try searching our database.

Newbie: How to use JTable?

Thread view: 
Falko Zurell - 04 Feb 2004 09:54 GMT
Hello,

as I wrote I'm new to Swing and JTables and the like.

I write an application wich will load a bunch of data (literature
entries in detail) from an XML file and display it in an JTable. I
managed to read the XML file and get the data in a form I can use to
fill the table. Now   my question: How do I use the JTable?

What I did by now:

I wrote my own TableModel extended from DefaultTabelModel to represent
my data (i think this class works fine)

In my application I first create an instance from my TabelModel class.

Then I create a new JTable and give it my TableModel instance in the
constructor.

Now I need to get my data into that table. For this I call the
setValueAt() method of the TabelModel-Object to fill the modell.

Then finally all the stuff will get displayd by calling show on the
parent frame.

----

My applications starts and the data gets readily read from the xml file.
I see the JFrame and the table. But there are no data in the JTable.
There are exact that much columns I intended to use with the right
column headings. But no cell data.

Do I have a major error in using JTable and TableModel? What is the
right way to fill the table? Calling the setValueAt() method on the
Model or on the JTable?

Thanks

Falko
Antti S. Brax - 04 Feb 2004 11:00 GMT
falko.zurell@avma.de wrote in comp.lang.java.gui:
> My applications starts and the data gets readily read from the xml file.
> I see the JFrame and the table. But there are no data in the JTable.
> There are exact that much columns I intended to use with the right
> column headings. But no cell data.

    You have the ideas right.

    Read the Java tutorial about JTables. Then make the smallest
    program you can that reproduces the bug (no XML parsing). Use
    DefaultTableModel directly. If DefultTableModel works then the
    bug is in your table model. If it doesn't then the bug is in
    the code that manipulates the table model.

Signature

Antti S. Brax - asb(at)iki.fi   Rullalautailu pitää lapset poissa ladulta
  http://www.iki.fi/asb/          http://www.cs.helsinki.fi/u/abrax/hlb/
       "Disconnect this cable to shorten, re-connect to lengthen."
         -- Instructions on Logitech's USB mouse extension cord.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.