🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: JTable: isCellEditable

#10067
From: Michael Kintzer
Date: Fri, 12 Nov 1999 00:00
44 lines
2198 bytes
I was already doing that.  The solution turned out to be to override JTable's
editCellAt() method and check the return code on isCellEditable() and not
prepare the editor if isCellEditable() returned false.

Thanks.

Ernesto Basc�n Pantoja wrote:

> Hi:
>
> Well, your overridden getTableCellRendererComponent(...) method receives a
> column as
> parameter. Its value is the index of the "viewed" column, not the index of
> its model, so,
> to obtain the right value, you must use:
>
> int modelColumn = myTable.convertColumnIndextoModel(columnParameter);
>
> and work with it to render the cells.
>
> Saludos
>
> Ernesto
>
> Michael Kintzer wrote:
>
> > I have a JTable constructed with a subclass of DefaultTableModel.  In my
> > implementation of MyDefaultTableModel, I override isCellEditable to
> > return true or false conditionally based on the value in a particular
> > column.  If the cell is not editable, I use a renderer to render the
> > cell's background gray.
> >
> > My problem is that if the column's are moved around, in some cases, even
> > though isCellEditable is (correctly) returning false, and the renderer
> > is correctly showing the gray background for what should be a
> > non-editable cell, the JTable prepares an editor anyway.  The reverse is
> > also true, after I move the columns around. i.e. isCellEditable returns
> > true (correctly), and the renderer paints a white background (again
> > correctly), but the JTable fails to create an editor.  Is this a bug in
> > JTable?
> >
> > Thanks for any insights,
> >
> > Michael Kintzer
Technical Details
Message-ID: <382C8B3F.299DB037@atm.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <38271072.A2C78F4E@atm.com> <38274D3C.411BF839@estudiantes.ucbcba.edu.bo>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 111d45,c849c62cef13890
X-Google-Attributes: gid111d45,public
From: Michael Kintzer <michaeki@atm.com>
Subject: Re: JTable: isCellEditable
Date: 1999/11/12
Message-ID: <382C8B3F.299DB037@atm.com>
X-Deja-AN: 547910749
Content-Transfer-Encoding: 8bit
References: <38271072.A2C78F4E@atm.com> <38274D3C.411BF839@estudiantes.ucbcba.edu.bo>
X-Accept-Language: en
Content-Type: text/plain; charset=iso-8859-1
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing