problem with key typed event of textfeild
i need to write a code to enter only numerical keys. i am using key typed event.
here is my code,
Code:
char ch=evt.getKeyChar();
if(!((char>='0'&& char<='9')||ch == KeyEvent.VK_BACK_SPACE||ch == evt.VK_DELETE))
evt.consume();
i am getting error at line 2(if(!..
Re: problem with key typed event of textfeild
Swing? AWT? something else?
To get proper help on a forum, you need to lean to be specific about your problem. Posting a SSCCE (Short, Self Contained, Correct (Compilable), Example) will always ensure that you get better help sooner.
Quote:
i am getting error at line 2(if(!..
When seeking help with an error, always post the complete, unedited error message or stack trace.
db
Re: problem with key typed event of textfeild
here is the erroe.sorry i could not enclose it in code.
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - unexpected type
required: value
found: class
at HOMEPAGE.tf3KeyTyped(HOMEPAGE.java:7149)
at HOMEPAGE.access$4900(HOMEPAGE.java:22)
at HOMEPAGE$57.keyTyped(HOMEPAGE.java:1164)
at java.awt.Component.processKeyEvent(Component.java: 6460)
at javax.swing.JComponent.processKeyEvent(JComponent. java:2829)
at java.awt.Component.processEvent(Component.java:628 2)
at java.awt.Container.processEvent(Container.java:222 9)
at java.awt.Component.dispatchEventImpl(Component.jav a:4861)
at java.awt.Container.dispatchEventImpl(Container.jav a:2287)
at java.awt.Component.dispatchEvent(Component.java:46 87)
at java.awt.KeyboardFocusManager.redispatchEvent(Keyb oardFocusManager.java:1893)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEv ent(DefaultKeyboardFocusManager.java:752)
at java.awt.DefaultKeyboardFocusManager.preDispatchKe yEvent(DefaultKeyboardFocusManager.java:1017)
at java.awt.DefaultKeyboardFocusManager.typeAheadAsse rtions(DefaultKeyboardFocusManager.java:889)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent (DefaultKeyboardFocusManager.java:717)
at java.awt.Component.dispatchEventImpl(Component.jav a:4731)
at java.awt.Container.dispatchEventImpl(Container.jav a:2287)
at java.awt.Window.dispatchEventImpl(Window.java:2719 )
at java.awt.Component.dispatchEvent(Component.java:46 87)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:703)
at java.awt.EventQueue.access$000(EventQueue.java:102 )
at java.awt.EventQueue$3.run(EventQueue.java:662)
at java.awt.EventQueue$3.run(EventQueue.java:660)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:676)
at java.awt.EventQueue$4.run(EventQueue.java:674)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 673)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:244)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:147)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:139)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:97)
Re: problem with key typed event of textfeild
Well, if you can't compile your source code you shouldn't be trying to run it. Post the compiler error.
db