Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: update JTable

Reply
Thread Tools

Re: update JTable

 
 
Daniele Futtorovic
Guest
Posts: n/a
 
      07-17-2008
On 2008-07-17 15:46 +0100, http://www.velocityreviews.com/forums/(E-Mail Removed) allegedly wrote:
> I create AbstractTableModel model, then create table new
> JTable(model) and add some data.
> Then I want to add or delete some columns to data. How can I update
> this JTable?


Use a javax.swing.table.DefaultTableModel instead of the
AbstractTableModel. It's got methods to do what you want.
<http://java.sun.com/javase/6/docs/api/javax/swing/table/DefaultTableModel.html>

The JTable registers listeners with its data and columns models. Updates
to the visual representation are best achieved by making these listeners
be notified. DefaultTableModel does that for you -- as a rule, however,
I'd encourage using a dedicated TableModel for almost all non-trivial
solutions. This applies to the TableColumnModel only to a lesser extent,
inasmuch as changes to the column structure are less frequent than
changes to the row structure.

--
DF.
to reply privately, change the top-level domain
in the FROM address from "invalid" to "net"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update On The Windows Phone 7 Update Update Lawrence D'Oliveiro NZ Computing 2 02-25-2011 08:03 AM
Putting a JTable inside a JTable cell? Tivo Escobar Java 1 04-12-2007 11:09 AM
How to move data from a CSV file to a JTable, and from a JTable to a CSV file ? Tintin92 Java 1 02-14-2007 06:51 PM
update JTable pat270881 Java 3 04-06-2005 09:19 AM
Custom JTable update problem Seref Arikan Java 1 01-26-2004 05:31 PM



Advertisments