• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Select vs Edit in JTable

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to programatically select and edit a cell in a JTable. The cell editor and renderer are JTextField components. My code is as follows:

What I get is a cell that appears selected, but the cursor is not present. If I type, text is added to the end of the text field, but still no cursor. If I click the cell, the cursor appears where I click and when I type, text appears at the point of the cursor within the text string.
What I want is to have the cell selected (current behavior) AND have the cursor appear at the end of the text string in the cell, ready for editing. Additionally, I'd like the entire text to be selected within the cell so typing replaces the current text.
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try setCaretPostition (or other related methods) from JTextComponent.
Bill
 
G Estes
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply. I tried this and got the same results. I think that the problem is with the actual "selection" vs "editing" state of the cell. If it's editing, then the caret should be visible, shouldn't it? It's almost like some event that needs to be fired, isn't.
[ November 05, 2002: Message edited by: Gil Estes ]
 
a wee bit from the empire
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic