keyListener in JWindow

Discussion in 'Java' started by Mahdi Dabestani, Jul 22, 2006.

  1. I can't control key events in JWindows.
    What should I do ?
     
    Mahdi Dabestani, Jul 22, 2006
    #1
    1. Advertising

  2. Mahdi Dabestani wrote:
    > I can't control key events in JWindows.
    > What should I do ?
    >

    Type more carefully and a lot slower? :)

    Do you mean "how do I capture key events that Swing/awt is eating"?
    If so you need to create a key handler by extending KeyAdapter. You
    probably only need to override the keyTyped method, which should
    extract the keypress from the event and send it to your model.
    Instantiate the key handler in your JWindow constructor and call
    addKeyListener() (inherited from java.awt.Component) to install it.


    --
    martin@ | Martin Gregorie
    gregorie. | Essex, UK
    org |
     
    Martin Gregorie, Jul 22, 2006
    #2
    1. Advertising

  3. Mahdi Dabestani wrote:
    > I can't control key events in JWindows.


    Have you tried using (or threatening) capital punishment?
    That often scares key events into line.

    > What should I do ?


    1. Post some (very short) compilable example of
    your code that does not work.

    2. Ensure you setFocusable(true) and requestFocus()
    on the JWindow or its main component.

    3. If 2. fails, ..see 1.

    Andrew T.
     
    Andrew Thompson, Jul 22, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AJ
    Replies:
    0
    Views:
    376
  2. AJ

    JWindow HELP!

    AJ, Apr 7, 2004, in forum: Java
    Replies:
    3
    Views:
    602
    Steve W. Jackson
    Apr 8, 2004
  3. Re: JWindow Handle

    , May 24, 2004, in forum: Java
    Replies:
    0
    Views:
    737
  4. Lee

    JWindow on the desktop

    Lee, Oct 6, 2004, in forum: Java
    Replies:
    3
    Views:
    887
    Andrew Thompson
    Oct 6, 2004
  5. Max

    JWindow KeyListener

    Max, Oct 29, 2005, in forum: Java
    Replies:
    4
    Views:
    3,783
Loading...

Share This Page