Key « JComboBox « Java Swing Q&A





1. All keys to a list, for example VK_A..Z for user to select    stackoverflow.com

I am making a program that allows user to custom keyboard shortcuts, for this i need the available keys to be displayed, what is the best way to achieve this in ...

2. Detecting when user presses enter in Java    stackoverflow.com

I have a subclass of JComboBox. I attempt to add a key listener with the following code.


        addKeyListener(new KeyAdapter() 
     ...

3. JFrame Combo box Event Key... HELP    stackoverflow.com

I am having a problem on what to use and what to code if I want my combo box be generated once the user type a key... like: once i pressed letter "A" ...

4. JComboBox loses keyboard events after setting custom UI    stackoverflow.com

I have the following problem : I need to set a custom UI for a JComboBoxComponent (to modify colors, arrow button etc.) Currently, I'm doing it in a constructor, like this :

public ...

7. key event on JComboBox    coderanch.com

8. JComboBox Keyboard Item Selection    coderanch.com

Right now, when you are in a JComboBox and you select a letter it takes you to the first item in the list with that letter. And then if you hit a different letter it again takes you to the item in the list beginning with that letter you typed. What I am wondering, is if there is a way that ...

9. Handling keyboard event in JComboBox without making it editable    coderanch.com

Hi Friends, I have a JCombobox and I would like to call some method if user press some key when it has focus. I know it is possible to work with keyListener if I make combobox editable. Problem is I couldnt make combobox editable. Is there any way to handle keyboard event in combobox without making it editable Thanks in adv. ...





10. ENTER KEY with JComboBox    coderanch.com

Hi I want to move the focus when user presses ENTER key. I have 2 comboboxes and then some textfields. I had implemented the KeyListener interface and overridedn keyPressed method. when i press enterkey on a combobox its not movinf to next feild.Its working fine with TextField.from one text field to another focus is movinf on press of ENTER key. Please ...

11. KeyListener of JComboBox    coderanch.com

12. key listener for editable combo box.    coderanch.com

13. JComboBox Key Selection    coderanch.com

Works out-of-the-box for me, both with the cross platform look&feel and the Windows system look&feel: //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); String[] contents = new String[26]; for (char c = 'A'; c <= 'Z'; c++) { String s = c + " item"; contents[c - 'A'] = s; } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComboBox combo = new JComboBox(contents); frame.getContentPane().add(combo); frame.pack(); frame.setVisible(true); In Java 6, ...

14. JComboBox and keypress    coderanch.com

All, I have given this some thought and came up with a solution... In the JComboBox's LisComboBoxModel (which is a subclass of DefaultComboBoxModel) I have introduced a Vector which holds the strings being displayed (based on the objects held in the model). That Vector is initialized whenever the model is constructed or refreshed: private Vector displayItems; .... @SuppressWarnings("unchecked") private void buildDisplayItems() ...

15. JComboBox ItemListener passing typed key to JTextField    coderanch.com

I am having a problem trying to change a GUI when the user selects a certain JComboBox list item. Everything works great if user clicks the item with a mouse, or with the arrow keys. However, when using the key accelerators, the issue arises. Basically, I have a JComboBox with an "Other" list item. If the user selects this item, I ...

16. KeyListener on JComboBox    forums.oracle.com

JTextField editor = (JTextField) combo.getEditor() .getEditorComponent(); editor.addKeyListener(this); public void keyReleased(KeyEvent e) {} public void keyTyped(KeyEvent e) {} public void keyPressed(KeyEvent e) { if (e.getKeyCode()==e.VK_ENTER) { String search = getString(); Boolean found = false; int m=0; for (int n=0; n