The combo box below has an array of numbers, being: 10, 90 80. etc etc. I want to have it when someone presses enter in the textbox with any value it displays that value in the combobox.
However, I do not want it to physically add it to the list of items in the combo box, only to temporary display it until a value is chosen in the combo box.
Text Box:
textField = new JTextField();
textField.setBounds(150,40,80,20);
getContentPane().add(textField);
textField.addKeyListener(new keyListener());
Enter listener:
public class keyListener extends KeyAdapter
{
public void keyPressed(KeyEvent e)
{
if (e.getKeyCode()==KeyEvent.VK_ENTER)
{
comboBox.addItem(TEMP_ITEM_HERE);
}
}
}
Combo Box:
comboBox = new JComboBox(cdata);
comboBox.setBounds(80,300,100,20);
getContentPane().add(comboBox);