Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

JTable with CellEditor peculiar focus problem  RSS feed

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ranchers,

I have a JTable with a group of editable & non editable cells.

Now I have following Listeners registered with JTable:
1> ListSelectionListener - > valueChanged method
2> MouseListener -> am handling double clicks

Coming to my editors. I have a TextField Editor, PasswordEditor and ComboboxEditor. I have registered FocusListener and KeyListener to my textfields to get required functionality.

Now when a user clicks on a editable cell. The textField inside the CellEditor gets Focus and everything is alright.

Here's my Focus problem:
When the user presses enter key; the selection is next row/same column... which is alrite too. But the textField does not get the focus.

I tried registering a FocusListener with the JTable...unfortunately I'm not able to get any text from the textField. code snippet is attached below:



Could somebody point out to me.. what I'm missing here? If you guys need I'll post the StringCellEditor code too.
Any other approach to get this thing working? I mean the text inside the cell should be HIGHLIGHTED on tab/enter key from JTABLE. I know selection behavior is default.

TIA
Ravi
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't tried it, but I found this thread at Java Forums that describes a couple of ways of catching/disabling the default action in a JTable.

Hope this helps!
Tom
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!