🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #10057

JTable and TableModelListener

#10057
From: Yael Raz
Date: Mon, 29 Nov 1999 00:00
46 lines
1754 bytes
Hi people,

I'm having trouble setting up an event listener for my JTable. My experience
in Java is minimal, so please bear with me.

The class that owns the panel that owns the list is Frame1 (surprise
surprise).
The frame's constructor initialises the table with the model - this part
works: I can see my data from the model.

The listener is set as follows:

public class Frame1 extends DecoratedFrame implements TableModelListener
{
    JTable jTable1 = new JTable();
    TableModel tableModel;
    ...

    public Frame1()
    {
        ...

       tableModel = new AbstractTableModel()
        {
            public int    getColumnCount()    { return 4; }
            ...
        };

         jTable1.setModel( tableModel );
        jTable1.getModel().addTableModelListener( this );
    }

    public void tableChanged( TableModelEvent e )
    {
        int nRow = e.getFirstRow();
        int nCol   = e.getColumn();
        ...
    }
}

For some reason, tableChanged never gets called when the table values are
edited.
I'd appreciate it if someone could point me in the right direction here.

Thanks!
Yael.
Technical Details
Message-ID: <FRp04.12884$MZ.88984@ozemail.com.au>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,233d1bc75a860621,start
X-Google-Attributes: gid111d45,public
From: "Yael Raz" <yaelr@locus.com.au>
Subject: JTable and TableModelListener
Date: 1999/11/29
Message-ID: <FRp04.12884$MZ.88984@ozemail.com.au>
X-Deja-AN: 554323360
Distribution: world
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2120.0
X-Trace: ozemail.com.au 943860197 203.108.34.232 (Mon, 29 Nov 1999 18:23:17 EST)
Organization: OzEmail Ltd, Australia
NNTP-Posting-Date: Mon, 29 Nov 1999 18:23:17 EST
Newsgroups: borland.public.jbuilder.java.swing