This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How to implement editable field in table to restrict to accept fixed length Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to implement editable field in table to restrict to accept fixed length" Watch "How to implement editable field in table to restrict to accept fixed length" New topic
Author

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

Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

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


Regards
Sudhakar
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Just another cross poster.
http://forums.sun.com/thread.jspa?threadID=5355748


luck, db
There are no new questions, but there may be new answers.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10175
    
    8

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.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270



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

Joined: Aug 26, 2008
Posts: 270

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

Joined: Aug 26, 2008
Posts: 270

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

Joined: Aug 26, 2008
Posts: 270

Any body please suggest me how to do it?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41178
    
  45
The code doesn't compile - it's missing the Main and PropertyStore classes. Post a simplified example that doesn't use those.


Ping & DNS - my free Android networking tools app
Mikko Kohtamäki
Ranch Hand

Joined: Dec 13, 2008
Posts: 112
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

Joined: Aug 26, 2008
Posts: 270

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
 
Consider Paul's rocket mass heater.
 
subject: How to implement editable field in table to restrict to accept fixed length
 
Similar Threads
How to specify a variable width column in an HTML page?
JTable -Adding Column and Fix Columns Problems
JTable
how to skip tab order from non-editable column
how to avoid tab order into noneditable column?(urgent)