How to trap the Delete Key..

Hi
I have implemented key handler for a text area and I want to do something when the delete key is pressed, but somehow the delete key press event is never trapped.
Any ideas?? Here is the code:
text_area.addKeyListener(new KeyAdapter(){
public void keyTyped(KeyEvent e){
if(e.getKeyCode() == e.VK_DELETE){
System.out.println("This was deltete");
I checked in the debugger....this method is never invoked for the delete key.
How do I trap the delete key event??
Thank you for your time.

I agree. Something like:
String actionName = DefaultEditorKit.deletePrevCharAction;
final Action deletePrevCharAction = textpane.getActionMap().get(actionName);
Action myAction = new AbstractAction()
public void actionPerformed(ActionEvent e)
System.out.println("Pressing backspace...");
deletePrevCharAction.actionPerformed(e);
textpane.getActionMap().put(actionName, myAction);
mrai3

Similar Messages

  • HT3986 Does anyone know how to enable the "Delete" key for logging on the Windows 7 partition on the latest iMac, via the latest Apple wireless keyboard? Many Thanks

    Hi All
    Does anyone know how to enable the "Delete" key for logging on the Windows 7 partition on the latest iMac, via the latest Apple wireless keyboard - the standard wired apple keyboard works fine via this key but not the new wireless keyboard?
    Many Thanks

    Holy crap, this fixes the issue.  At least temporarily it has.  I should add that my issue was single finger forward/back swipe stopped working on the magic mouse in Firefox since Mavericks came along.  I have been fighting this since I upgraded to Mavericks a few months ago.  Thank you, tbirdvet.  You have no idea how much easier you just made using my iMac again.
    Message was edited by: wadems

  • How to trap the first key?

    Hello World,
    I am using JTable in that I am using custom TextField as a Editor Component. Now I want to trap the first key pressed in the textfield.
    I am using public boolean editCellAt(int row,int column,EventObject e) method. In this method I get the value of �e� as a null if I press any key. So I can not trap the event here.
    The next try is to putting KeyListener in textfield class, this is also not working because it gets called after EditCellAt method.
    I tried to override the processKeyBinding() method but this seems to trap all the key pressed and not allow me to navigate also.
    Can anybody provide me the solution how I can trap the first key only.
    Thanks in advance,
    Sachin Dare.

    Hello World,
    I am using JTable in that I am using custom TextField
    as a Editor Component. Now I want to trap the first
    key pressed in the textfield.what do you want it for?
    [.. usual l aproaches snipped ]
    The reason this is not working is that JTable uses a very uncommon way to route this first keyEvent: it comes via Jtable.processKeyBindings which first tries to start the edit with it (buggily "forgetting" to pass the keyEvent along...) and if this started the edit it will pass both keyStroke and keyEvent to the editorComponent's processKeyBindings. At his time the editorComponent is part of the container hierarchy.
    So a possible solution (did not try it, though) might be to have a ComponentListener on the editorComponent, set a flag when being added to the table and reset the flag when receiving the first KeyStroke in proocessKeyBinding after the componentEvent. Alternatively, you might try to set/reset the flag as a clientProperty in table.processKeyBindings.
    Greetings
    Jeanette

  • Since I must create a folder to send questionable emails I may read or refer to later, how do I change the action of the delete key so it'll be just as easy?

    After recognizing and following the suggestions I skimmed in the Q&A, my trash is still being emptied against my wishes. Everything looked familiar involving settings, etc. I think and hope and will re-check that I've all the correct settings applied. I would like to verify; Do I have to really create a folder to send my email to instead of trash/delete if I want to view it later? If so that sucks, but I'll obviously work around it. My frustration with this matter over the years caused me to stop reading and here I am, agitated. I can probably figure out how to create a folder and MAYBE even figure out how to make it somewhat easier than it sounds to move the emails there. My biggest obstacle is learning how to program the delete key on my keyboard to send them there, because it's simply common sense to everyday users not to mention a terrible habit occurred over the many years of practicing to strike the delete key when a "I'll get to it later" email is highlighted AND without any worry knowing you can always find it in the trash because you know the last time the trash was emptied/permenantly deleted. Can you somehow make this a little more user friendly. It sucks to not be able to trust having an email when you go back to look for it. Can you imagine having to pay attention anything for longer than 5-7 seconds when you're trying to find that one email amongst possibly thousands in one of my in boxes because you're scared to death to delete anything that may be of value one day in the future, or not. Pretty please tell me I'm on the wrong track here and there's a simple solution and how to find it. And

    IMHO, the mistake is to put anything in Trash if you think you'll ever want to look at it again. Do you ever "file" actual paper documents in the real Trash bin, down there on the floor?
    However...
    Your Trash folder may be on the email provider's server and subject to their housekeeping regime. Have a look at your account settings; if the account uses IMAP then you might try setting it to use a local Trash folder, for instance in your Local Folders account. That should put emptying of Trash under your control and safe from the whims of any third parties. But in my book, using Trash for persistent storage is perverse. Or as you might put it, it sucks.
    I'd set up a Pending folder, and use QuickFolderMove, or use star and a filter, or a tag and a filter to park indeterminate messages in it.
    The delete key is for deleting things, and nothing else.

  • How would I make it so that when "deleting" an image I can make it so that the delete key does it or a button I put on the application?

    How would I make it so that when "deleting" an image I can make it so that the delete key does it or a button I put on the application?
    I want it so that I can use either a button on the designer window or the delete key. I know how to do the or part but the trouble I'm having is coding the button in.
    if (LastImageClicked != null && (e.Key == Key.Delete || Button))
    This is the code that I have in the format I'm looking for I just don't know how to do it. Thanks for your help!

    There are a number of things which are unclear about your question.
    I'll tell you one way to approach this though.
    Handle Window.PreviewKeyDown.
    <Window
    Window.PreviewKeyDown="Mainwindow_PreviewKeyDown"
    Code behind
    private void Mainwindow_PreviewKeyDown(object sender, KeyEventArgs e)
    if (e.Key == Key.Delete)
    File.Delete("p001.jpg");
    I don't know enough about what you mean by LastImageClicked  but you need some way of knowing which path you are going to delete.
    Then you might well have a problem if it's showing in an image control.
    You will need to copy the picture off disk into a new bitmapimage object.
    If you just do
    <Image Source="p001.jpg"
    Then that image will grab the file and you won't be able to delete it - you'll  get an error.
    In my experimental code p001.jpg is set as content copy always so it ends up next to the exe in the bin when the solution compiles.
    You would probably want a full path to a file there.
    Hope that helps.
    Recent Technet articles:
    Property List Editing;  
    Dynamic XAML

  • How can I change the key to delete a message from the delete key to command-delete like it is in the finder?

    These new forums confuse me... Sorry.
    I often think I am typing in another window but I'm actually typing while Mail.app is selected.  When I discover this, I often (without really thinking) start whacking the delete key.  When I whack the delete key, of course, a message is moved to the trash.  So, without really thinking about it, I delete three to six messages.  Go ahead -- call me stupid.  But...
    If delete is not used to delete files in the Finder, then why is it used to delete files in Mail?
    One group suggested making customer keyboard macros.  Sounded like a plausible solution.  I could make a customer keyboard macro so that delete did nothing (or something benign) and make command-delete delete the message.  Alas, using the Apple => System Preferences => Keyboard => Keyboard Shortcuts => Application Shortcuts gave me no Joy because it won't let me do either of those.  When I try to enter either delete or command-delete into the "Keyboard Shortcut" box, it just beeps at me.
    Does anyone here have a suggestion?
    Thank you,
    pedz
    p.s.   I can get the deleted messages back using Undo (repeatedly) but I think that is new with Lion.  So life isn't tragic but it still is an interface that I'd like to change if I could.

    You can define your own custom keystrokes in System Preferences -> Keyboard.  I'm not 100% sure that this blocks the old keystroke, though, and am posting from my iPad and can't check that at the moment.

  • Why does the delete key on the keyboard go backward?  How can I make it go the other way?

    I'm used to a PC keyboard that enables me to delete characters from where my cursor it to the next space to the right.  The keyboard I have with my Mac, alas, is frustrating for me to use because it goes backwards from what I am used to.  Is there a fix to this?  My PC keyboard has a backspace button in addition to the delete button, so it is very straightforward for me that way.

    The delete key, if the cursor is placed mid sentence, will remove letters etc forwards from that cursor point.   If you are deleting from the end of a sentence, the backward facing long arrow above the return key will delete backwards from that point.
    For groups of letters or sentences, highlight them and press delete.
    It is one of those situations where you should learn the new approach because the rest of the system is geared to it.
    Message was edited by: seventy one

  • How to trap the Escape & Enter key ?

    I want to close the window when user presses escape key & want to trap the enter key for some action.
    Help will be higly appreciated.

    import javax.swing.*;
    public class KeyItIn extends JFrame{
       JTextArea jta[] = new JTextArea[2];
       public KeyItIn() {
          getContentPane().setLayout(new java.awt.GridLayout(2,1) );
          for(int i=0; i<2; i++){
             jta[i] = new JTextArea();
             jta.setBorder(BorderFactory.createEtchedBorder());
    jta[i].addKeyListener(new EventKeyHandler() );
              getContentPane().add(jta[i]);
    setDefaultCloseOperation( EXIT_ON_CLOSE );
    pack();
    class EventKeyHandler extends java.awt.event.KeyAdapter{
    public void keyPressed(java.awt.event.KeyEvent e){     
    jta[0].setText(" Key Typed: "+(char)e.getKeyCode());
    jta[1].setText(" Key code = "+e.getKeyCode() );
    public static void main(String[] args) {
    new KeyItIn().show();

  • How to set the "delete" button in Mail to actually delete instead if Archive Google Mail messages...

    I know these kinds of questions are asked a lot, but I just wanted to ask my specific question for a nice specific answer.
    I understand Gmail's thoughts on archiving and labels, but it makes gmail a beast to work with on mail clients.  I FINALLY have everything set up perfectly on my Mac's Mail app so that everything syncs and I get no duplicate messages.
    The only issue I have is that when I highlight emails and press the "trash" icon in the toolbar (and hit the delete key I assume) the message(s) is/are archived in the All Mail folder instead of going into the "Trash" folder.  The only way I can truly delete messages is to drag and drop them into the Gmail/Trash folder in the side bar, which can get tedious. 
    Is there anyway to set the "delete" icon and delete key to actually send messages to the trash instead if archiving without causing syncing issues, or do I just need to stick with the drag and drop method?
    Thank you.
    Respectfully,
    JAC151

    Take a look here: http://jeffschuette.com/2012/03/07/setting-up-apple-mail-to-rock-and-roll-with-g mail/
    Jeff explains why it happens and how to deal with it.

  • Strange items deletion in various applications as if the Delete key being pressed.

    I work with a T420 laptop docked in a docking station.
    The following strange phenomenon is happaning:
    Occasionally, Items are being deleted or attempt to be deleted in various applications as if the Delete key is being pressed constantly.
    Examples:
    1. The Outlook window is open, left mouse click on the Inbox folder results in all emails being deleted.
    2. Explorer window is open, left mouse click on one of the files or folder results in attemp to delete the file or folder. Clicking 'NO' results in an endless loop of attempt to delete.
    3. Google window is open (IE), clicking on one of the letters in the search box, results in this letter being deleted.
    4. Open Task manager, results in attempt to delete the first task in row.
    When docked out the laptop from its station, this strange behavior stopped.
    Needles to say, that I replaced the external keyboard and the docking station itself, but it did not help.
    HAS ANYONE ENCOUNTERED SUCH A PROBLEM? What do I do?!

    I am having a similar issue that I can consistently recreate. I was finding that emails were "randomly" getting deleted from various folders. It was driving me crazy! I keep my Outlook inbox fairly well organized in that I keep emails in there if they require further action. I don't keep my Deleted folder organized however, so I was getting chunks of emails going from my Inbox to my Deleted items folder and it became very difficult to find all of the deleted emails that I still needed to action..... Here is how I can recreate this:
    Laptop is off of the docking station and open. Outlook has focus with an email highlighted in my inbox. I close the lid and place the laptop onto the docking station. The email that had focus is now in the deleted folder. Again, I can recreate this virtually every time. Please help!

  • Uninstalling applications? and wheres the delete key.

    Sorry to sound like a complete idiot. However Ive had my macbook for a full day. First impressions are exceptional, however Ive only ever used DOS, Windows PCs over the last 13years, and this is completly new to me.
    First question, which does sound dumb, is where is the delete key? I know theres a back space, but no delete for deleting characters in front of the cursor??? If so what key is it?
    Secondly, how do I uninstall apps? In Windows, it could be done via add/remove programs, however I have no idea what Im looking for to remove installed programs on the hdd.
    Any advice would be appreciated.
    Thanks Paul

    Hi
    As for the remaining 1% that Terence did not deal with, these are applications that are more complex in structure and typically install files in various locations. These apps come with their own uninstaller. Check whether an app has such an uninstaller when you install it. Typically, uninstall info is to be found in the Readme file that comes with the application. As Dr. Smoke says:
    "Never install an application until you know how to uninstall it!"
    Uninstalling applications
    Matthew Whiting
    Message was edited by: matthew whiting

  • Using the delete key

    To delete several letters or spaces at a time I used to be able to push the delete key and hold it down once and it would delete everything until I released it. Now I have to press the delete key for each and every letter or space I want deleted. How can I change this?
    Thanks,
    Starflower

    All keys should repeat automatically when you hold them down.
    goto your system preferences-->Keyboard & Mouse
    then select the keyboard tab.
    move the key repeat rate slider a few times. Then check the delete key to see if the reenables the repeat.

  • Safari 5.1.7 Disabling the delete key from going back a page

    Everytime Im on Safari and I want to delete some text Safari goes back to the previous viewed page after I press the delete key. This is very frustrating. Does anybody know how to disable. Please help

    HI John,
    That would require remapping. This thread has some links available that may help.
    http://discussions.info.apple.com/message.jspa?messageID=11553590
    Possibly http://www.hotkey.com. You can assign Command + Backspace as a shortcut for Delete.
    Carolyn

  • How to trap ALT-Space key combo. ?

    Hi,
          Does anyone know how to trap Alt-space?  The user is probing a PC board and may want to keep their eyes on the work.  The space-bar makes a nice big "next" button, and the Alts on either side seem a natural choice for "back".  But, when I try to trap the Alt-key/space keyboard-event, the program nevers sees it.  Instead, a file dialog is displayed, as if Alt is trapped by the VI-menu-bar - which isn't even displayed!
    Cheers.
    When they give imbeciles handicap-parking, I won't have so far to walk!

    I believe Alt-Space is a keyboard shortcut in Windows XP to bring up the window menu for any app...so it's not just a LabVIEW thing. Further, it appears that Windows grabs that key combination before a LabVIEW event structure can get it.  I don't know any way around this behavior, since Windows appears to be taking matters into its own hands with certain key combinations.  My advice would be to use a different key combination for your app.
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • Recently, the delete key and rt click delete do not remove a message. Have to restart T'Bird to be able to delete a message. Using v 24.5.0

    Using Thunderbird 24.5.0, W7, up-to-date in fixes
    The delete key and the right click delete suddenly don't delete a messsage.
    Restarting Thunderbird and then they both work.
    What should I be looking for?

    I tried that - but same result.

Maybe you are looking for

  • Systems are not available in the NWDS but in the Web-client

    I'm at presnt using the VC 7.11 in the web client. For enlarging the default components by a couple of own one I'm trying to use VC in the NWDS. Now I'm facing the problem that the default systems (Busniess Objects, Portal Content, Portlet Applicatio

  • Jpeg preview images -- how to check

    Whenever I take my USB stick to a photolab to print images, if I don't save from Photoshop with "Image Previews" turned off (and most of the time I forget to turn it off), the dopy photolab machine recognises the previews as separate images and prese

  • JQuery Ui draggable not working in iOS app

    Hey there, I have built an iOS mobile app using EA and PGB. I have an element which uses jQuery Ui's draggable function. It works perfectly in a web browser but in the final app I am unable to drag the element. I have tried loading the script with bo

  • HT4260 Can I use a Netgear Universal WN3000RP Wi-Fi Range Extender?

    Can I use a Netgear Universal WN3000RP Wi-Fi Range Extender with my Airport Express to extend the range? If so, is there anything that I need to do in order to configure my computer for it to work properly? Are there any disadvanges to doing this (sp

  • Reverting to a previous save on icloud

    hi, how do i revert to a previous saved version of a table in numbers on icloud? its only giving me the option to revert to previous versions saved to my mac hard drive.