wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes combobox is not updating in Swing GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "combobox is not updating in Swing GUI" Watch "combobox is not updating in Swing GUI" New topic
Author

combobox is not updating in Swing GUI

praveen bhurlekar
Greenhorn

Joined: Apr 11, 2010
Posts: 3
I am adding item in the combo box within a fucntion and I am calling that function from actionListener of a button.
The combo box is getting populated, I am able to print the value using SOP but it is not updating in GUI.

PSB the sample code :

// Leeloo.java


Thanks.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

Praveen,
Welcome to the Ranch. I have edited your post to incorporate code tags. UseCodeTags
Also please avoid using words like PSB. UseRealWords

To get the most out of the Ranch, please do take out time to review http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

The combo box is getting populated, I am able to print the value using SOP but it is not updating in GUI.

This is contradictory. Did you open the combo drop down to view the data after populating it?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

Ok. I tried your code. I got some compiler errors which I fixed. In the future please PostRealCode

Root cause of your problem is in your actionPerformed. What do you think it does?
praveen bhurlekar
Greenhorn

Joined: Apr 11, 2010
Posts: 3
Hi Mangesh,

sorry for the incomplete code.

first my Gui shows the combo-box.
Then on button click combo-box is populated, I print the value from combo box using System.out.println("");

but when i open GUI it is not updated.

mangesh,
if you found the problem please let me know how to rectify it.

I need to update the combo box within the fucntion only.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

My name is Maneesh not Mangesh.
I have already told you what is causing the problem in my earlier post
praveen bhurlekar
Greenhorn

Joined: Apr 11, 2010
Posts: 3
my program is going in infinite loop at runtime.
while putting Leeloo l = new Leeloo(); outside actioPerformed() function.

Maneesh,
please help.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

On line 43 you create a new instance of Leeloo which is completely unrelated to the current Leeloo instance. It has its own set of combo boxes and all. Try calling simply "getDataFiles", without the "l." This will call this method on your current instance.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: combobox is not updating in Swing GUI
 
Similar Threads
How does inner class access outter class functions?
Different Cursors
Editable JComboBox which maintains history...
How does inner class access outter class functions?
Using a custom renderer for JComboBox