|
From: Bumsys on 17 Jul 2008 09:46 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?
From: Daniele Futtorovic on 17 Jul 2008 10:13 On 2008-07-17 15:46 +0100, Bumsys(a)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"
|
Pages: 1 Prev: web development Next: BigDecimal(String) vs. BigDecimal(double) [Floating-point arithmetics] |