🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

JTable & ColumnModel

#12879
From: Jari Nurminen
Date: Thu, 29 Oct 1998 00:00
40 lines
2208 bytes
Hi,

First of all I'd like to ask if anybody knows a good document (kind of a
tutorial) which explains the events when I'm using a JTable. If I would
have that I think wouldn't be asking my second question ;-)

And the second question is why isn't this working:
- I use JTable to display different query-results = the results might have
any number of rows and columns.
- I use my own table model which is inherited from AbstractTableModel
- I try to use my own column model (inherited from DefaultColumnModel) to
do a very simple things (e.q. setting the width of the first column).

The application sets my table and column model for JTable (setModel &
setColumnModel) at startup time and after that the reference is untouched.
I only modify the data in the table model and fire appropriate events when
something is changed (fireTableStructureChanged & fireRowAdded etc.).

The problem is that JTable shows only the first state of the table model
(setting the width of the first column works fine), BUT if I modify
something in the table model no changes are shown in JTable. The first view
is still there.

What do I do wrong? 
What happens to the column model if the table structure changes in the
table model?
It fires tableChanged() in JTable but this shouldn't do anything to the
column model  reference it just creates columns again from the data model
but this never happens despite the fact that AutoCreateColumnsFromModel is
set to true.

If I don't use my own column model everything works fine, but then setting
that column width gets complicated: I have to do it in the View part and I
have to do it always when the table structure has changed. But my aim is to
do this in the Model part. 

I hope somebody could help me somehow.

cheers,
		Jari
Technical Details
Message-ID: <01be0348$9cd9ca40$2dd96fc2@pc12.gordion.com>
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,a1a19ae339f87577,start
X-Google-Attributes: gid111d45,public
From: "Jari Nurminen" <nospam_nurminen@gordion.com>
Subject: JTable & ColumnModel
Date: 1998/10/29
Message-ID: <01be0348$9cd9ca40$2dd96fc2@pc12.gordion.com>
X-Deja-AN: 406318478
Organization: Gordion- Business Consulting Ltd.
Newsgroups: borland.public.jbuilder.java.swing