0
How to make editable jcombobox in java
1. how to make editable combobox in java. 2.Without using loop 3.Using keytyped and keyevent 4. Kindly give suggestion on it
3 Respostas
0
String[] options = { "Option 1", "Option 2", "Option 3", "Option 4"};
JComboBox cb = new JComboBox(options);
cb.setEditable(true);
0
nope...using keytyped
0
That just creates a combobox and makes the combobox editable. If you're wanting to listen for keypress events that will depend on what keys you want to listen for etc. You can make a keylistener which will accept input from all keys, but then you'd need to write the code as to what to do when whichever key you're waiting for is the one that is pressed. If memory serves correctly and depending on which OS you're on the enter key and up down arrow keys should work be default, but I may be mistaken as I don't use swing much anymore.
If you can explain in detail what exactly you're attempting to accomplish I will try to help further before I have to leave in a few hours.
https://docs.oracle.com/javase/tutorial/uiswing/events/keylistener.html
https://docs.oracle.com/javase/7/docs/api/javax/swing/JComboBox.html
https://docs.oracle.com/javase/7/docs/api/javax/swing/JComboBox.html#setEditable(boolean)
https://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html