File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes jComboBox Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "jComboBox Help" Watch "jComboBox Help" New topic
Author

jComboBox Help

Mathew Mintalm
Ranch Hand

Joined: Feb 21, 2010
Posts: 103

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

Joined: Jul 26, 2007
Posts: 10451
    
    8

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!


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Mathew Mintalm
Ranch Hand

Joined: Feb 21, 2010
Posts: 103

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

Joined: Jun 13, 2009
Posts: 2200
    
    7
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

Joined: Feb 21, 2010
Posts: 103

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
 
subject: jComboBox Help