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 / Databases / July 2006

Tip: Looking for answers? Try searching our database.

Resetting JTables

Thread view: 
cp - 07 Jul 2006 00:45 GMT
I'm running out of ideas on this. Basicly I wrote my own console to act as a
more userfriendly interface to interact with an underlyding MySQL database.
Whenever i issue a query i get a pop-up window displaying the results in a
JTable.
My problem is that I would like to reset / re-initialize this JTable so that
the next query I issue, clears the JTable and populates the table with the
news result.
I have tried resetting the model of the table using:

DefaultTableModel model = new DefaultTableModel(data, columnNames);
table.setModel( model );

But that doesnt seem to work, it just displays the result below the results
of the original query.

I add the coloums and rows of the query-result into two seperate vectors.

Any idea?

- CP
Rhino - 07 Jul 2006 15:01 GMT
> I'm running out of ideas on this. Basicly I wrote my own console to act as
> a
[quoted text clipped - 18 lines]
>
> Any idea?

I haven't tried this myself but shouldn't you be executing the
fireTableRowsDeleted() method from AbstractTableModel after you delete the
old rows and then fireTableRowsInserted() from the same class after you have
added the new rows?

--
Rhino
RC - 12 Jul 2006 20:14 GMT
> DefaultTableModel model = new DefaultTableModel(data, columnNames);
> table.setModel( model );

Here is what I did:

if (!model.getDataVector().isEmpty())
    model.getDataVector().removeAllElements();


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



©2008 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.