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 trap delete KeyEvent.. 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 trap delete KeyEvent.." Watch "how to trap delete KeyEvent.." New topic
Author

how to trap delete KeyEvent..

danish shaikh
Greenhorn

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)
consume=true;
if(code==KeyEvent.VK_DELETE && flag==true)
consume=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...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how to trap delete KeyEvent..
 
Similar Threads
How to capture the delete key?
Problem~~
Strings n Scriplet
Key Event listener question.
JTextField on getText() method