KJW
KJW

Reputation: 15251

Java: JTextField with JComboBox

How do you go about creating a JTextfield with a drop down embedded into it? So you can use the drop down to select a value which will show up in the JTextfield. I am not looking for autocomplete but the ability to select and show values from combobox in the same textfield. For example a browser's url box and it can also act as a drop down showing urls that match it. I would like the drop down button to show up however.

Upvotes: 0

Views: 775

Answers (1)

Juvanis
Juvanis

Reputation: 25950

If there is no specific reason of why you want to use JTextField, I suggest you to use an editable JComboBox. It is a combobox that you can type customized text on the top option field and also you have the ability of selecting the customized text and process it from combobox. Take a look at this example, it might be the solution that you are looking for: Editable ComboBox with Java

Upvotes: 1

Related Questions