To say that I am not offended at being called "incompetent" in what i thought was supposed to be a friendly forum would be lying.

I stated long ago that i was NEWBIE to java.

All i meant by my original post was why not MAJORITY of people can enter a consonant with keyListener().

Forget all the little bugs about navigating away. I just mean why can't they even ENTER a consonant from the keyboard.

The problem is i can enter a char but my online friends can't. They're following my instructions as is and NOT doing anything weird.

I am sorry if insulted Java by saying it was full of bugs but i just don't get why they can't enter a consonant.

But people don't have to insult me personally by calling me names on posts I can't delete and feel offended by.

Dani AI

Generated

This thread shows a classic keyboard-handling gotcha rather than a mysterious Java bug. As reported inconsistent character input and as and pointed out, there was no sample code or environment data to inspect. The following is a concise, practical checklist and a tiny example that cover the causes seen most often in threads like this.

Common causes and quick checks

  • Focus: KeyListener only receives events when its component has keyboard focus. Ensure the component is focusable, call requestFocusInWindow() after the UI is shown, and check isFocusOwner() during debugging.
  • Wrong event: For character input use keyTyped(KeyEvent) and e.getKeyChar(). keyPressed/keyReleased report physical keycodes and can behave differently for IME/dead keys.
  • Component choice: Adding a KeyListener to a top-level window often fails; prefer adding it to the interactive JComponent (or use a focused JTextField for text entry).
  • Platform/IME/layout: Different OS/JRE and international keyboard settings can change which events are generated. Test on a plain JTextField to separate app logic from environment issues.
  • Prefer Key Bindings: In Swing, InputMap/ActionMap (key bindings) give more predictable behavior across focus traversal than low-level KeyListener.

Minimal diagnostic snippet

panel.setFocusable(true);
panel.requestFocusInWindow();
panel.addKeyListener(new KeyAdapter() {
    public void keyTyped(KeyEvent e) {
        System.out.println("Typed: " + e.getKeyChar() + " code=" + e.getKeyCode());
    }
});

If the snippet prints expected characters locally but not for others, the problem is almost always environmental: JRE/OS version, keyboard layout, IME, or another component stealing focus. A small reproducible test program that logs getKeyChar(), getKeyCode(), isFocusOwner(), plus the OS and JRE versions, will quickly reveal whether the cause is focus, event type, or platform-specific behavior.

Recommended Answers

All 6 Replies

I think Java will get over its hurt feelings just fine, but the point of the post you are referring to is that just because you cannot get something to work correctly does not mean that it's "full of bugs". Claiming that it is is just a cop out. That was the only thing he was pointing out.

I think Java will get over its hurt feelings just fine, but the point of the post you are referring to is that just because you cannot get something to work correctly does not mean that it's "full of bugs". Claiming that it is is just a cop out. That was the only thing he was pointing out.

You don't have to call someone incompetent. Why aren't you able to answer my question about not entering char if there is a solution. Why can't my program run on a MAC?

commented: Stop crying and start learning -6

Why aren't you able to answer my question about not entering char if there is a solution.

Perhaps I missed it, but I haven't seen you post any code, which means people can only speculate what might be the trouble. If you want more help debugging it, post the code and perhaps someone can offer you a precise reason.

Simply forget the whole thing. I want this post deleted PLEASE.

It runs on the mac now that i compiled to version 6 Java.

How do i delete my own posts?

Simply forget the whole thing. I want this post deleted PLEASE.

It runs on the mac now that i compiled to version 6 Java.

How do i delete my own posts?

You can edit posts within thirty minutes of submission. After that, they are permanent.

You certainly are cranky about a request that you post some code if you want a more specific reason for the key listener behavior. People can't see over your shoulder, you know.

To say that I am not offended at being called "incompetent" in what i thought was supposed to be a friendly forum would be lying.

I stated long ago that i was NEWBIE to java.

All i meant by my original post was why not MAJORITY of people can enter a consonant with keyListener().

Forget all the little bugs about navigating away. I just mean why can't they even ENTER a consonant from the keyboard.

The problem is i can enter a char but my online friends can't. They're following my instructions as is and NOT doing anything weird.

I am sorry if insulted Java by saying it was full of bugs but i just don't get why they can't enter a consonant.

But people don't have to insult me personally by calling me names on posts I can't delete and feel offended by.

No one called you any names. Just stated that you blame others when it is you that you can't get something to work.
And instead of posting your code and asking for help like many others you started throwing accusation.
What was the point of your post. If you wanted your code fixed where is your code, and where is your question.


Also this the thread he was referring to:
http://www.daniweb.com/forums/thread216050.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.