• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JComboBox Selected Object not visible

 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
i have a JComboBox with DefaultComboboxModel has 3 items in that,

After some event i set the new model with diffrent items.

issue is:

when i select the item from the combo box its not showing the selected item, but in code it is giving the correct selected item

 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How exactly are you setting the new data? By updating the existing model or creating a new model with the new data and then setting it to the combo box?
 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have created new.
 
Rob Spoor
Sheriff
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show us the creating and setting code?
 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Creation part

Vector<String> itemList = getItemList();
oComboBox = new JComboBox();
oComboBox.setModel( new DefaultComboBox(itemList))

updating Part

oComboBox.setModel( new DefaultComboBox(getNewItemList()));
 
pete stein
Bartender
Posts: 1561
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You likely have a bug in the code that you still aren't showing us. If you are still desiring help in a forum such as this, you'll be far better off to show a small compilable program that demonstrates your problem. Otherwise I fear you'll continue to show snippets of irrelevant code.
 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi pete,

The problem is solved, in the action listener of teh combo box i was calling the update Combobox model again so it keep calling in the recursion. so its solved the problem

regarding the code, I am extremely sorry fo this. in my office i am not able to copy the code from my system. and i have to use the Internet (ranch) in the remote desktop

 
pete stein
Bartender
Posts: 1561
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chiranjeevi Kanthraj wrote:hi pete,

The problem is solved, in the action listener of teh combo box i was calling the update Combobox model again so it keep calling in the recursion. so its solved the problem

Well, I'm very glad that you solved the problem and that you posted the solution for all to see. You also can see that your ultimate problem had nothing to do with the code that you've posted, so hopefully you'll see this as a lesson as well. Many here recommend that folks with similar problems create and post an SSCCE, and I agree (please see the link for details on how this works). Otherwise you'll be in for a very frustrating experience here.

Much luck.
 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chiranjeevi Kanthraj wrote:
regarding the code, I am extremely sorry fo this. in my office i am not able to copy the code from my system. and i have to use the Internet (ranch) in the remote desktop


This is precisely the reason we encourage SSCCE code (check out the link Pete provided)
Many a times, generating the SSCCE helps the user identify the problem himself.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic