| Author |
Disable KeyEvent
|
Rajeev Kashyap
Greenhorn
Joined: Sep 07, 2004
Posts: 19
|
|
Hi, In texfield , it should limit the value to take upto 1000. If it is type more than 1000 then key event should not take place on textfield Thanks in adv
|
 |
Serghei Jelauc
Ranch Hand
Joined: Jul 24, 2002
Posts: 128
|
|
|
Try to use JFormattedTextField.
|
SCJP 1.4 <br />SCBCD 1.3<br />SCWCD 1.4
|
 |
Pritam Barhate
Greenhorn
Joined: Nov 25, 2004
Posts: 15
|
|
Yes, using JFormattedTextField can be one option. Here is another option, that may be more suitable to your purpose. you should exted javax.swing.text.PlainDocument to crate your own custom document class and then override its method. If you want to know how to use this feature in detail see the Javadoc for JTextField. It has an example on how to limit a textfield to only uppercase letter. I hope you derive your own version from it.
|
Pritam Barhate<br />A magic combination of <b>Code</b> & <b>Fire</b> : <a href="http://www.jroller.org/page/codefire/Weblog" target="_blank" rel="nofollow">codefire</a><br />----------------------------------- <br />My Open Source Projects:<br /><a href="https://acemdi.dev.java.net/" target="_blank" rel="nofollow">AceMDI</a>: A easy, yet powerful MDI framework that manages windows as Tabs.
|
 |
Rajeev Kashyap
Greenhorn
Joined: Sep 07, 2004
Posts: 19
|
|
|
Thanks Serghei Jelauc & Pritam. Both are good solutions but Serghei's solution is simple to implement.
|
 |
 |
|
|
subject: Disable KeyEvent
|
|
|