This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Karnati Sudhakar
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just another cross poster.
http://forums.sun.com/thread.jspa?threadID=5355748
 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any body please suggest me how to do it?
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Mikko Kohtamäki
Ranch Hand
Posts: 112
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic