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

How to implement editable field in table to restrict to accept fixed length

 
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a JTable in which 4th column is editable but i want to make this column to accept only fixed length input means user should not be able to enter data more than what is fixed at execution time for that cell.

Regards
Sudhakar
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just another cross poster.
http://forums.sun.com/thread.jspa?threadID=5355748
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Darryl Burke:
Just another cross poster.
http://forums.sun.com/thread.jspa?threadID=5355748



Sudhakar,
After ~88 posts you should know better.
Please do take out time to go through this.
 
Karnati Sudhakar
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Maneesh,

I am sorry.I was unaware of that policy.I was in hurry to get the answer.I never thought about the people who answer our queries and their precious time.Once again many thanks to people who answer our questions(Sometimes stupid) very patiently.

What should i do now? I did not get the answer either here or there?
Please help me..



Regards
Sudhakar
 
Karnati Sudhakar
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried to extend the DefaultCellEditor and created a FixedLengthTextField for the 4th column.But it is not working last editable column is accepting unlimited data.

Example1.java




FixedLengthTextField.java




FixedLengthPlainDocument.java



Please help me..

Regards
Sudhakar
 
Karnati Sudhakar
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
should i override the method getColumnClass?

What kind of object should be assigned to the data value for the particular cell?

Regards
Sudhakar
 
Karnati Sudhakar
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Any body please suggest me how to do it?

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code doesn't compile - it's missing the Main and PropertyStore classes. Post a simplified example that doesn't use those.
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Confused, is your problem that when cell goes to edit mode (in that moment) you want set fixed length of characters for your editor component (eg. JTextField) ?
 
Karnati Sudhakar
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Confused, is your problem that when cell goes to edit mode (in that moment) you want set fixed length of characters for your editor component (eg. JTextField) ?



Yes.I did this by overriding the isCellEditable method and setting the length of the editable cell there.

The code doesn't compile - it's missing the Main and PropertyStore classes. Post a simplified example that doesn't use those.



Thanks Ulf.Issue resolved.I used DefaultTableModel instead of AbstractTableModel.

Regards
Sudhakar
 
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic