• Post Reply Bookmark Topic Watch Topic
  • New Topic

urgent.event consume  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi every body.Can anybody help me regarding event consuming. I want only alphabets to be entered in the textfield.For this i am using consume() method of AWTEvent class.It works fine in Applications but doesn't in applets.Can any explain me the reason behind this & also what should i do to achieve the same in applets. It's really very urgent.
Thanx in advance
Clkanth
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello here the Consume works
class General
{
public static void gp_key_accept(String iptype,KeyEvent ke)
{
int kc=ke.getKeyCode();
if (iptype.equals("alphabets"))
{
System.out.println(ke.getKeyCode());
if ((kc>=KeyEvent.VK_A) && (kc<=KeyEvent.VK_Z))<br /> {<br /> System.out.println("HAI"+ke.getKeyChar());<br /> }<br /> else<br /> {<br /> System.out.println("CANCELLED"+ke.getKeyChar());<br /> ke.consume();<br /> }<br /> }<br /> if (iptype.equals("alphanumeric"))<br /> {<br /> if ( ((kc>=KeyEvent.VK_A) && (kc<=KeyEvent.VK_Z)) | |
(kc==KeyEvent.VK_BACK_SPACE) | | (kc==KeyEvent.VK_UP) | |
(kc==KeyEvent.VK_DOWN) | | (kc==KeyEvent.VK_LEFT) | |
(kc==KeyEvent.VK_RIGHT) | | (kc==KeyEvent.VK_HOME)| |
(kc==KeyEvent.VK_END)| | (kc==KeyEvent.VK_INSERT)| |
(kc==KeyEvent.VK_DELETE) | | (kc==KeyEvent.VK_SPACE) | |
(kc==KeyEvent.VK_DECIMAL) | |(kc==KeyEvent.VK_COMMA))
{
System.out.println("HAI"+ke.getKeyChar());
}
else
{
System.out.println("CANCELLED"+ke.getKeyChar());
ke.consume();
}
}
}
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!