Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Re: update JTable (http://www.velocityreviews.com/forums/t626078-re-update-jtable.html)

Daniele Futtorovic 07-17-2008 02:13 PM

Re: update JTable
 
On 2008-07-17 15:46 +0100, Bumsys@gmail.com 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"


All times are GMT. The time now is 07:26 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.