Can't capture escape-key event

I have made a class which implements KeyListener and have added to a dialog. The keyPressed(KeyEvent e) method is called with common keys but not with the escape-key. How can I make this work with the escape?

This works for me:
protected JRootPane createRootPane() {
    ActionListener escLis = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            dispose();
    JRootPane rootPane = super.createRootPane();
    KeyStroke ks = KeyStroke.getKeyStroke (KeyEvent.VK_ESCAPE, 0);
    rootPane.registerKeyboardAction(escLis, ks, WHEN_IN_FOCUSED_WINDOW);
    return rootPane;
}I'm pretty sure that registerKeyboardAction() has been deprecated so you'll probably want to replace that portion of the code.
Col

Similar Messages

  • Escape Key Event in JTable

    I have a KeyPressed event method in a java file where I am using the F3 and Escape keys. I have a JTable in the java file with values in it. The user can select any row in the table and when you press F3 or Escape key some methods get called up which deselect the chosen rows in the table. This works fine with the F3 key but when I put the exact same code in the Escape key event, nothing happens.
    However when the focus goes off the JTable to another componement on the screen, pressing the Escape key now works. I want to have the Escape key working when the focus is on the table. Any suggestion please?

    thanks for you response but I am still a bit confused. When I press the Esc key whilst the focus is on the JTable nothing happens but when the focus is off the JTable, all the methods in the Esc event get called and the rows in the table get deselected.
    Is there any way of not having the JTable consuming the Esc key so the Esc key will work when focus is on the JTable.
    I have a key pressed method registered to the class (not the JTable). Say that my class is called 'xinternetDesktop', my code is this:
    public void xinternetDesktop_KeyPressed(java.awt.event.KeyEvent keyEvent) {
    int code = keyEvent.getKeyCode();
    switch (code) {
    case KeyEvent.VK_ESCAPE : /*Escape key*/
    resetListSelectionBidsAndOffers();
    break;
    case KeyEvent.VK_F3 : /*F3*/
    resetListSelectionBidsAndOffers();
    break;
    Could u give any suggestion please.
    Thank you

  • How can I capture mouse click events on BSP or Web Dynpro ABAP Screen

    hi Guys,
    Currently we have a user inactivity problem,
    the requirement is: if user is clicking on BSP/Web Dynpro ABAP screen, he/she is considered active. so we need an mechanism to capture the mouse click event.
    Using Firebug, we found that this js is in the iframe which contains BSP/web dynpro scrren: /sap/public/bc/ur/nw5/js/languages/urMessageBundle_en.js
    we want to find this js file & put in some javascript code to track user's mouse click, but i cannot find it on server.
    while in ie if we type http://host:port/sap/public/bc/ur/nw5/js/languages/urMessageBundle_en.js
    this file can be downloaded, means this file is there.
    Any one can help on this issue? find the js file or another way to capture the mouse click event.
    Thanks a lot with points!

    Hi  Feng Guo,
                        We can not capture mouse click events on Web Dynpro ABAP Screen . I am not sure about BSP. But as for as I know the portal keep active the iViews until unless mouse clicks happens.
    But for your problem I think you can get solution by setting iView Expiration to some more time period.
    Regards,
    Siva

  • Capture desktop key event to control my screen capture app

    I want to write a screen capture program to capture screen when I am playing fullscreen game or other desktop window application. But the java screen capture program can only receive key or mouse event when it is focused. So how do I capture key event when I am focusing other app or fullscreen app?
    Do I have to use JNI and call some OS specific API. My target OS is WinXP. Help or suggestions are appreciated!!

    Hi All,
    I was wondering if there is a way to capture the top-most
    window or dialog box. This is something that will
    generally be running outside of the JVM....We,
    as programmers, need a Rectangle instance that describes the area
    of interest to be captured (i.e., location and size).
    Thus, a routine that interfaces to the Native windowing system (Toolkit?)
    might look something like:
    Rectangle rect = tk.getRectangleForTopMostComponent();
    Does anything like this exist?
    Thanks!
    - DocJava

  • Capturing Enter key event from text box

    In my application, there are a number of text boxes. I want to create a feature where an enter key even is seen and specific function executed depending on which text box was in focus when the enter key was pressed. Currently I am able to capture an enter key event on the whole page. How do I do that specifically for a text box?
    This application is done in HTML, javascript and Adobe AIR.
    Thanks
    Binu
    www.verseview.info

    Hi
    That's true that Flex4.5 SDK under Flash builder Burito doesn't listen Enter key in Text Area for KeyUp or KeyDown event.
    Here I found a work around you can use.
    Add an eventlistener to the component in actionscript and set the useCapture=true next to eventlistener function. Now you can listen enter key for KeyUp or KeyDown Event
    Hope this helps
    Rush-me

  • KeyListener does not capture Arrow key Events in textField

    Love................
    I added a key listener to TextField it does not detect
    Arrow Keys events in keyTyped, KeyPressed,KeyReleased methods
    why?????
    I want to shift focus from a textfield to other component
    on capturing Arrow key Pressed How

    Here is a Java demo where it works since it is not a printable character you must get the keyCode:
    http://java.sun.com/docs/books/tutorial/uiswing/events/example-swing/index.html#KeyEventDemo
    public class KeyEventDemo ... implements KeyListener ... {
    ...//where initialization occurs:
         typingArea = new JTextField(20);
         typingArea.addKeyListener(this);
    /** Handle the key typed event from the text field. */
    public void keyTyped(KeyEvent e) {
         displayInfo(e, "KEY TYPED: ");
    /** Handle the key pressed event from the text field. */
    public void keyPressed(KeyEvent e) {
         displayInfo(e, "KEY PRESSED: ");
    /** Handle the key released event from the text field. */
    public void keyReleased(KeyEvent e) {
         displayInfo(e, "KEY RELEASED: ");
    protected void displayInfo(KeyEvent e, String s){
         char c = e.getKeyChar();
         int keyCode = e.getKeyCode();
         int modifiers = e.getModifiers();
         tmpString = KeyEvent.getKeyModifiersText(modifiers);
         ...//display information about the KeyEvent...
    }

  • 3.2.3;Capture Escape key on all along a Frame?

    A frame has several components like buttons, textfield, Combo,GridControl and so on. For some reason which i don't know why, The rows on gridControl disappears and replaces with blank rows, if Escape key pressed immediately after this Frame loaded.
    And an error message raises says some of the conditions on rowSet which is bound to grid are null.
    I debugged this frame and couldn't find the bug. Now needed some how to trap the Escape key and disable it. Please advice.
    null

    repost

  • Capture 'Enter' key event

    Hi,
    Is there any way we can capture the event when a user presses the enter key inside a text field?

    Hi andrewquay
    you can capture the enter key by adding the following code in the textfield's change event.
    if(xfa.event.change == "\u000a")
    xfa.host.messageBox("enter key is pressed");
    mail: [email protected]

  • How can I capture Microsoft EventSource Events on a Windows Phone?

    I use
    Microsoft EventSource Library to create events to instrument our applications. For Windows Applications running on Windows 7/8/8.1 I can use xperf
    to capture the events (xperf.exe" -start UserLogger -on GUID -f User.etl).
    But how can I do this on a Windows Phone 8.1?
    I use Win8.1 Pro (x64), VS2013 Community Edition with Update4 and try capture a trace with the custom events on my Lumia 1320 Dev Preview Update Build 8.10.14203.

    Hi Andre,
    First, sorry about the inconvenience Franklin brought to you.
    Developer Power tools can be used to capture ETW log, but I think it will not work for custom events. Check the
    thread replied by Eric.
    AFAIK, the option to capture custom events only opens to Microsoft OEMs as mentioned in
    this article.
    And I just found the following uservoice in our
    official uservoice channel.
    https://wpdev.uservoice.com/forums/110705-dev-platform/suggestions/6101326-enable-collection-of-custom-etw-events-to-etl-fil
    I think you can vote on that thread to push that.
    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    Alan Yao
    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

  • Can i capture laser pointer events in Flash?

    Hi.
    I have some people who are doing a medical presentation. Of course they are using PowerPoint and a couple of flash movies. When they launch their Flash movies from within the powerpoint they want to slide the flash presentation using the Laser Pointer.
    I made the flash files to slide at click on the stage. But that laser pointer doesn't have a click, It has two buttons wich launch somekind of event though USB of forward and backward which the powerpoint recognizes.
    So can flash recognise those, do any of you have any experience with this things? Can i listen globaly to all event that are triggered in flash to see if any of those come up?
    Tnx.

    FMLE will not directly mux audio connections from different sources. You could try possibly using a "Virtual Audio Cable", which is a outside program. Search Google for it.
    If you want to have more control over what you broadcast, I suggest using a 3rd party program such as Telestream Wirecast, or Xsplit..
    Xsplit is a realtively cheap alternative to Wirecast which is pricey.
    Check them Out..

  • Can't capture VK_Down key in jtextfield

    Hi frnds,
    I have a JTextField and i need to recognize when the user presses the down arrow key on it.
    What i have done is i am extending JTextfield and have added a keylistener to it and checking for getKeyChar()
    help please
    thanxxxxx

    chandransuraj wrote:
    Hi frnds,
    I have a JTextField and i need to recognize when the user presses the down arrow key on it.
    What i have done is i am extending JTextfield and have added a keylistener to it and checking for getKeyChar()
    Use the InputMap and ActionMap.
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.KeyEvent;
    import javax.swing.AbstractAction;
    import javax.swing.Action;
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    import javax.swing.KeyStroke;
    import javax.swing.WindowConstants;
    public class InputMapExample {
        InputMapExample() {
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            JTextField tf = new JTextField();
            String key = "arrow-down";
            Action action = new AbstractAction() {
                public void actionPerformed(ActionEvent ae) {
                    System.out.println("Down pressed");
            tf.getActionMap().put(key, action);
            tf.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), key);
            f.add(tf, BorderLayout.NORTH);
            f.setSize(400,300);
            f.setVisible(true);
        public static void main(String[] args) {
            new InputMapExample();
    }

  • How can I capture delete user event in Active Directory 2008 using Powershell command

    Hi,
    In my Active Directory every user have own home drive in the file server. When I delete user I also need to delete folder from the server. 
    My target is make the process automated, so that when I delete user account form AD, the folder associate with user also delete.
    Can I write any power shell script to grep the delete event  and remove folder from file server.
    Thanks
    Tamim Khan

    You can setup event viewer to provide alerts (email alerts) for event id 630.
    Find an existing Event ID 630 entry, right click on it and "Attach Task To This Event...."
    Follow the wizard.
    ** Event ID Sample **
    Event ID: 630
    Type: Success Audit
    Description: User Account Deleted:
    Target Account Name: %1 Target Domain: %2
    Target Account ID: %3 Caller User Name: %4
    Caller Domain: %5 Caller Logon ID: %6
    Privileges: %7
    - Chris Ream -
    **Remember, if you find a post that is helpful, or is the answer, please mark it appropriately.**

  • How to send Remote controller key event

    Hi Sir,
    Can anyone tell me "how to send key event from "Remote
    Controller" to Flex application?
    for example. I want to control the Flash player or my Flex UI
    application from remote controller such as use firefly
    controller/streamzap controller/Gyration controller. Normally user
    will use mouse or keyboard to enter/generate event, now I want to
    use "Remote controller" to generate the key event. In Flex, how can
    I capture the key event from "remote controller"? Any sample code
    to provide that will be good.
    Thanks.
    Lin

    Here's a couple related threads
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=583877
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=712386
    I'd also suggest exploring the Search Forums available on the left,
    which is how I found those threads:
    http://onesearch.sun.com/search/onesearch/index.jsp?qt=focus+traversal+tab+text&subCat=siteforumid%3Ajava57&site=dev&dftab=siteforumid%3Ajava57&chooseCat=javaall&col=developer-forums

  • Can't capture key event in applet

    Hi,
    Currently i'm developing an applet. However, i fail to capture the key event in the applet. The key that i fail to capture is VK_TAB. Any idea to handle this?
    Thanks in advance!

    to capture key event, u need to
    1. addKeyListener
    2. focus on that component (yourApplet must focusable)

  • Key event capture

    I can't find a way to capture the key events of the special key on multimedia keyboards, just like play/pause, browser or music..
    Any ideas?

    You probably can't. They have their own drivers to handle those specialties and Java (as far as I know) doesn't have support for those.

Maybe you are looking for