Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

combobox is not updating in Swing GUI

 
praveen bhurlekar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My name is Maneesh not Mangesh.
I have already told you what is causing the problem in my earlier post
 
praveen bhurlekar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my program is going in infinite loop at runtime.
while putting Leeloo l = new Leeloo(); outside actioPerformed() function.

Maneesh,
please help.
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic