• 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

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: 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
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.
 
We noticed he had no friends. So we gave him this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic