Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Jtable Cell editing validations

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I need to validate values entered into a table cell. I need to see if the entered value is atleast 7 chars and call a validation method. I need to do these validations as soon as 7 chars are entred. I tried extending CellEditorListener for my adaptor, but editingStopped metohd is firing only after I leave the cell and since I allready left the cell, I don't know how to get the value in the just edited cell as getEditingColumn is giving me -1 in the editingStopped Method.
Also, when user presses the SAVE button, I need to verify if any values are changed for the table (Only one column is editable) and fire a correpsonding save method.
Thak you for your help...
-- Rambo
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You must use a JTextField with your own DocumentModel which can take control of all inputs just in time.
You must specify an editor like this:
e.g.
JTextField tf2 = new JTextField(yourDocumentModel,null,0);
tf2.setHorizontalAlignment(JTextField.RIGHT);
TableCellEditor editor = new DefaultCellEditor(tf2);
 
Rambo Rambabu
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. This approach works.
reply
    Bookmark Topic Watch Topic
  • New Topic