Article View: borland.public.jbuilder.java.swing
Article #12971Re: populating JTable on the fly rather than hard coding the data
From: zimmerer
Date: Wed, 14 Oct 1998 00:00
Date: Wed, 14 Oct 1998 00:00
43 lines
1883 bytes
1883 bytes
hello,
try to make a class:
public class TModel extends AbstractTableModel implements TableModel {
private Vector data = new Vector();
}
add public methods for adding and deleting elements in the vector
and overwrite the TableModel interface (perhaps the default implementation
fits, too)
use this class as the model for the table.
JTable table = new JTable(new TModel()):
you can also use different, more difficult data structures within the TModel
class,
all you have to do is adapt the methods for adding and deleting and the
TableModel interface
alex
Madhusudan Chaganthi (Madhu) wrote:
> Hi
> I have a situation wherein I have a blank JTable in an application, only
> the columnName appears in the GUI rest all being empty. When the user
> clicks on a button, the JTable needs to populate it with the data which
> comes in with this button click under this column.
>
> I was trying DefaultTableModel with just the columnName. When I tried to
> add the data using addRow, nothing happens. I've tried setDataVector and
> other such methods too !!
>
> Could anyone tell me as to where I can get an example program or
> concepts for using JTable with dynamic data rather than hard coded data
> ?
>
> Thanks
> Madhu
Technical Details
Message-ID:
<3624B5D1.DC780489@cimag.de>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<3624A5BD.9B05E1DB@cdc.gov>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,ecf0d7a095d3a983 X-Google-Attributes: gid111d45,public From: zimmerer <a.zimmerer@cimag.de> Subject: Re: populating JTable on the fly rather than hard coding the data Date: 1998/10/14 Message-ID: <3624B5D1.DC780489@cimag.de> X-Deja-AN: 400995681 Content-Transfer-Encoding: 7bit References: <3624A5BD.9B05E1DB@cdc.gov> To: "Madhusudan Chaganthi (Madhu)" <mvc9@cdc.gov> Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing