Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help in JComboBox

 
Akalya Baskaran
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

PLease help me in creating a ComboBox with textfield and dropdown list goes like this: When i type a text in the textfield and press "Enter" key,the typed text should be added to the dropdown.
Also the dropdown list should contain all the values entered in the previous page.


 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understood you well, you would attach ActionListener to your JTextField component. The event would be triggered when you enter text and press the Enter key. So accordingly, your actionPerformed(ActionEvent event) method would contain the code to get the text from the field and add it to JComboBox (and probably then clear the text field).

Did you try to implement anything so far? Nobody's going to provide a complete solution for you... Try to follow the directions above and if you have any more doubts feel free to ask again with the code you get.
 
Akalya Baskaran
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didnt try anything still.I will write the code in actionPerformed() method and will let you know.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic