Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Editable drop down combo box  RSS feed

 
Heather Marie
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I have an editable combo box that has three values (not counting null.) I need to capture the user's input and do some calculations. Using an array, how do I assign the selection to a variable (double?)
Heather
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably want to create a FocusListener and use the FocusLost method.

Mark
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the Javadocs for JComboBox, you will see that this class as a getSelectedItem() method. Whether you use a listener or not, this is the key method to get what the user typed or selected in the combobox. If you are using straight AWT and not Swing, look at the docs for ComboBox instead. I'm willing to bet it has a similar method, but I'll leave that to you to discover for yourself.

Layne
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Layne Lund:
If you look at the Javadocs for JComboBox, you will see that this class as a getSelectedItem() method. Whether you use a listener or not, this is the key method to get what the user typed or selected in the combobox. If you are using straight AWT and not Swing, look at the docs for ComboBox instead. I'm willing to bet it has a similar method, but I'll leave that to you to discover for yourself.

Layne


True, but you can't call getSelectedItem() while you are in the middle of using the JComboBox without a Listener. You can call it anywhere outside the JComboBox though.

Mark
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Swing/AWT...
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!