This is a discussion on Problem JComboBox Editable getInputMap - Java ; Hello Friends, I have some problem . I am using JComboBox. I have used getInputMap() on the JComboBox. The problem is that : ---------------------------This code works after the combobox is editable--------------------------------- getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"),"Process"); getActionMap().put("Process",new AbstractAction("Process") { public void actionPerformed(ActionEvent evt) { ...
Hello Friends, I have some problem . I am using JComboBox. I have used
getInputMap() on the JComboBox. The problem is that :
---------------------------This code works after the combobox is
editable---------------------------------
getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"),"Process");
getActionMap().put("Process",new AbstractAction("Process")
{
public void actionPerformed(ActionEvent evt)
{
switch (mode)
{
case ADDITION:
System.out.println("Addition");
break;
case MODIFICATION :
System.out.println("Modification");
break;
case DELETION :
System.out.println("Deletion");
break;
case DISPLAY :
System.out.println("Display");
break;
}
}
}
);
---------------Where as This code does not work after the combobox is
editable------------------
getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ENTER"),"Process");
getActionMap().put("Process",new AbstractAction("Process")
{
public void actionPerformed(ActionEvent evt)
{
switch (mode)
{
case ADDITION:
System.out.println("Addition");
break;
case MODIFICATION :
System.out.println("Modification");
break;
case DELETION :
System.out.println("Deletion");
break;
case DISPLAY :
System.out.println("Display");
break;
}
}
}
);
only the difference is of the Key. i.e. ENTER & ESCAPE.