• 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
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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.
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic