This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

JComboBox Selected Object not visible

 
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • 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

 
Bartender
Posts: 11445
18
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have created new.
 
Sheriff
Posts: 21804
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • 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
  • 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()));
 
Bartender
Posts: 1561
  • 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
  • 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
  • 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
Bartender
Posts: 11445
18
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • 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.
 
Water! People swim in water! Even tiny ads swim in water:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!