Article View: borland.public.jbuilder.java.swing
Article #9049Re: how to create a read-only JTable?
From: Greg Hamer
Date: Wed, 07 Jun 2000 00:00
Date: Wed, 07 Jun 2000 00:00
33 lines
1722 bytes
1722 bytes
The way that I do it is extend JTable and override editCellAt:
public boolean editCellAt(int row, int column, java.util.EventObject e){
if (isEnabled())
return super.editCellAt(row,column,e);
else
return false;
}
or you can muck with the isCellEditable method in your model, perhaps by
adding a setEnabled method to the model and checking its value.
M Le <wildcard_mcl@hotmail.com> wrote in message news:393ed7a6@dnews...
> Hi,
>
> Is there an easy way of forcing the entired JTable not editable?
> I've looked thru all the JTable API, hoping to find some thing like
> setEditable(boolean), but couldn't find any. There's a isCellEditable()
> method, but no setCellEditable().
>
> I have a simple table with all cells contain simple, short text entries.
> I need them to be read only.
>
> I'm guessing that I need to use a JTextField for each cell, and then
> setEditable(false) on each cell? This is rather tedious. I supposed
> I could extend JTextField and make my own non-editable cell
> object, but all of this just to make a read-only text table?
>
> Any suggestion?
>
> Thanks!
> -ML
>
>
Technical Details
Message-ID:
<8hmlrg$cqb5@bornews.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<393ed7a6@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,6cc3b685d29e3672,start X-Google-Attributes: gid111d45,public From: "Greg Hamer" <ghamer@corp.netzero.net> Subject: Re: how to create a read-only JTable? Date: 2000/06/07 Message-ID: <8hmlrg$cqb5@bornews.borland.com> X-Deja-AN: 632384628 References: <393ed7a6@dnews> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Newsgroups: borland.public.jbuilder.java.swing