• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jComboBox Help

 
Mathew Mintalm
Ranch Hand
Posts: 103
Eclipse IDE Firefox Browser Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I made my jComboBox with 3 Strings inside:



And i have my text field called textArea

and now I would like to add "Action" for my jComboBox. If I will press for example "First" from my ComboBox on my textArea will appears "First" (yes "First", and I will press "Next" on my textArea should appear "Next" - same text as was in jComboBox)

And I made something like:



Anyone can help me how can i do it?
 
Maneesh Godbole
Saloon Keeper
Posts: 10976
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can get the selected item (hint) or the selected index (hint) from the combo box. Once you have the index you can get the item at the selected index (hint)
Check the API for methods which will let you do this.
Once you have the item, well you have the required string!
 
Mathew Mintalm
Ranch Hand
Posts: 103
Eclipse IDE Firefox Browser Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, thank you. Can you tell me now whats wrong with my code? I really dont have any other ideas (I made this code based on Your hints)



It works but not as it should, it show me first string all the time
 
Rob Camick
Ranch Hand
Posts: 2476
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've been given the link to the Swing tutorial multiple times and asked to read the relevant section. The combo box tutorial shows you how to use listeners.

You've also been asked to post a SSCCE when you encounter problems after reading the tutorial.

You have done neither, therefore I don't feel any need to waste my time and repeat information that is found in the tutorial and API.
 
Mathew Mintalm
Ranch Hand
Posts: 103
Eclipse IDE Firefox Browser Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok it works now. It was wrong because Object matim was final.

Everything is ok now.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic