Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Possible to use items in comboBox to prefix file name?  RSS feed

 
Alice Hampton
Ranch Hand
Posts: 217
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I have a comboBox full of id's - is it possible that when I choose said id (click it) it will then transfer over into my textField where I can use that as a prefix for my filename

( the file can be created just by having a name in the text field it doesnt need to already exists)
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, I don't understand your problem.

Post your SSCCE that demonstrates what you have attempted. All you need is a frame with a combo box and text field. Then when you select an item you populate the text field with the selected value.
 
Alice Hampton
Ranch Hand
Posts: 217
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there Rob I was just curious as to whether or not that was actually possible - I have to try and get it sorted today.Thankyou for your reply

*Edit

The code I have did what I asked but it was merely retrieving the first item that was added into the comboBox and placing that into the txt field. I thought I would need to use the comboBox but obviously convert it to string first. Will I have to set it up to override what ever is clicked from the comboBox after it first places the first item from the comboBox?

 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the section from the Swing tutorial on Handling Events on a Combo Box. You would use an ActionListener to listen for a user selection, not a PopupMenuListener.

And the code you posted is NOT a SSCCE.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!