• Post Reply Bookmark Topic Watch Topic
  • New Topic

Limiting the length of text in JTable column  RSS feed

 
Manoj Tyagi
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
I am using JTable to display messages from database for updating. Now, as this message field is editable in JTable, user can enter the message of any length. But I want to restrict the length of message during the time of editing JTable itself. How this can be done.
I tried this by adding keylistener to table & then on key press, checking the length of this message. But unfortunately table(or cell) is not listening for key listener.
What may be the problem. Please give me some guidance.
Manoj Tyagi
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the Sun tutorial on JTextFields. What you do is set up the editing for a textfield to limit the entry. You then use this field as the column editor.
 
Manoj Tyagi
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul,
it really worked.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!