File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes how to trap delete KeyEvent.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to trap delete KeyEvent.." Watch "how to trap delete KeyEvent.." New topic

how to trap delete KeyEvent..

danish shaikh

Joined: Nov 09, 2004
Posts: 21
Hi All,
I m creating a Text Editor in Java..
I m new to Java n learnt by my own.
1> i have to redirect the keyEvent of BackSpace n delete keys..
i have successfully built the logic to redirect the back space key ..
by first consuming it...
But my problem is that the Delete Key event is not consuming
i hav used the same logic for backspace but it working so plz help me
the logic is..
public void keyPressed(KeyEvent ke)
int code=ke.getKeyCode();
if(code==KeyEvent.VK_BACK_SPACE && flag==true)
if(code==KeyEvent.VK_DELETE && flag==true)

2> i also wants to make the deleted word as a striked one but that too is
not working whereas the same for underline attribute is working so plz
help me....

StyleConstants.setUnderline(set, true); /// working
StyleConstants.setStrikeThrough(set,true); ///not working

plz help me its quite urgent...looking for ur replies....
Thanks in Advance...
I agree. Here's the link:
subject: how to trap delete KeyEvent..
jQuery in Action, 3rd edition