• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

JComboBox Selected Object not visible

 
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have created new.
 
Sheriff
Posts: 22800
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic