Win a copy of Spring Boot in Practice this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

combobox is not updating in Swing GUI

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
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
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
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

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
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22667
127
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic