Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to set and highlight text in JTable cell on selection and/or invoke cell editor directly.

Reply
Thread Tools

How to set and highlight text in JTable cell on selection and/or invoke cell editor directly.

 
 
news.rcn.com
Guest
Posts: n/a
 
      07-12-2004
I have a JTable whose cells display values derived from the data in the
TableModel (rather than the the data itself.)

When a cell is selected (by mouse or keyboard navigation) I need to
1) show the raw data from the table model (not the derived data)
2) highlight it to show it will be replaced after editing.
This needs to be done before the user types into the cell.

I can't figure out how to catch an event when a table cell is selected. My
best guess is to is overide the 'isCellEditable' in the table model and try
to get the cell renderer, then get the Component that draws it.
and load the raw data and select it. However, I could not get this to work.

Alternatively, if I could the cell editor directly when the table cell gets
selected, I could load the raw data in there and let the user have her way
with it. Can I do this? It seems that nobody cares about the editor until
the table cell gets a keystroke typed into it; then the editor UI takes over
the table cell real estate (from the renderer).

I'd appreciate any help or suggestions. Thanks in advance.

jim cant
http://www.velocityreviews.com/forums/(E-Mail Removed)


 
Reply With Quote
 
 
 
 
Chris Smith
Guest
Posts: n/a
 
      07-12-2004
news.rcn.com wrote:
> I have a JTable whose cells display values derived from the data in the
> TableModel (rather than the the data itself.)
>
> When a cell is selected (by mouse or keyboard navigation) I need to
> 1) show the raw data from the table model (not the derived data)
> 2) highlight it to show it will be replaced after editing.
> This needs to be done before the user types into the cell.
>
> I can't figure out how to catch an event when a table cell is selected. My
> best guess is to is overide the 'isCellEditable' in the table model and try
> to get the cell renderer, then get the Component that draws it.
> and load the raw data and select it. However, I could not get this to work.


Instead of this, why not just implement the cell renderer to return the
desired look for a selected component? The cell will be re-rendered
when it is selected, after all.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Putting a JTable inside a JTable cell? Tivo Escobar Java 1 04-12-2007 11:09 AM
Jtable row/cell/column selection issue apattin Java 2 04-28-2006 04:24 PM
Highlight selection of <DIV>'s text content in a Modal Dialog tungchau81@yahoo.com Javascript 2 01-19-2005 07:25 PM
JTable with row selection, but no cell selection Simon Niederberger Java 2 01-07-2005 04:17 PM
JTable cell selection event Don Java 4 10-30-2003 09:58 AM



Advertisments