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

add values to JCombo Box dynamically[urgent]  RSS feed

 
netharam ram
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm unable to add avlues to JComboBox after it has been created.If we use the add method I receive an error that this is an Improper Model.Please post a code snippet to add,insert values after creating the JComboBox with some values.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The addItem( Object ) method should be used to add new items to the JComboBox. The add() method is just inherited from Component, and it thinks your trying to add another Component inside the JComboBox.

-Nate
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!