Re: update JTable

Discussion in 'Java' started by Daniele Futtorovic, Jul 17, 2008.

  1. On 2008-07-17 15:46 +0100, 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"
     
    Daniele Futtorovic, Jul 17, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tivo Escobar
    Replies:
    1
    Views:
    7,345
    manusa
    Apr 12, 2007
  2. Seref Arikan

    Custom JTable update problem

    Seref Arikan, Jan 26, 2004, in forum: Java
    Replies:
    1
    Views:
    2,992
    Christian Kaufhold
    Jan 26, 2004
  3. pat270881

    update JTable

    pat270881, Apr 5, 2005, in forum: Java
    Replies:
    3
    Views:
    15,042
    John McGrath
    Apr 6, 2005
  4. Tintin92
    Replies:
    1
    Views:
    1,712
    Andrew Thompson
    Feb 14, 2007
  5. Haircuts Are Important
    Replies:
    3
    Views:
    330
    Haircuts Are Important
    Jun 4, 2013
Loading...

Share This Page