java - How to check KeyListener input? -
in java.awt.event.keylistener, how check if user enters "+" or "- "?
here's code example of how this:
textfield field = new textfield(); field.addkeylistener(new keylistener() { public void keytyped(keyevent e) { final char achar = e.getkeychar(); if (achar == '+') { system.out.println("+ typed"); } if (achar == '-') { system.out.println("- typed"); } } public void keypressed(keyevent e) { } public void keyreleased(keyevent e) { } });
Comments
Post a Comment