File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JComboBox Selected Object not visible Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JComboBox Selected Object not visible" Watch "JComboBox Selected Object not visible" New topic
Author

JComboBox Selected Object not visible

Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

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


-Chiru
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10246
    
    8

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?

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

i have created new.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

Can you show us the creating and setting code?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

Creation part

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

updating Part

oComboBox.setModel( new DefaultComboBox(getNewItemList()));
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
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

Joined: Feb 18, 2008
Posts: 289

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

Joined: Feb 23, 2007
Posts: 1561
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

Joined: Jul 26, 2007
Posts: 10246
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JComboBox Selected Object not visible