KEYLISTNER FOR EDITABLE COMBOBOX

//i have created this combobox:

JComboBox o_String= new JComboBox();

// and added a keylistner this way:

o_String.addKeyListener(new java.awt.event.KeyAdapter() {

public void keyReleased(KeyEvent ke) {

o_String_keyReleased(ke);

}

public void keyPressed(KeyEvent ke) {

o_String_keyPressed(ke);

}

});

//with these functions

void o_String_keyReleased(KeyEvent ke)

{

if (ke.getKeyCode() == KeyEvent.VK_F12

System.out.print("F12");

}

void o_String_keyPressed(KeyEvent ke)

{

if (ke.getKeyCode() == KeyEvent.VK_F1)

System.out.print("F1");

}

//but it doesn't work..any one can tell me where is the problem?

// i wanna do somtning when i press F1 or F12 ,,,

[833 byte] By [masdara] at [2007-11-27 10:15:02]
# 1

Your caps lock key is broken.

Don't forget to use the "Code Formatting Tags",

see http://forum.java.sun.com/help.jspa?sec=formatting,

so the posted code retains its original formatting.

A better approach is to use "Key Bindings":

http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html

camickra at 2007-7-28 15:37:04 > top of Java-index,Desktop,Core GUI APIs...