Win a copy of Svelte and Sapper in Action this week in the JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Creating a dialog in a listener

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, so I'm trying to have an actionListener that, when triggered, creates a dialog with a progress bar. Seems like this would be a pretty common thing to do - you hit a button, a popup comes up saying 'Loading...' or whatever while it's processing something. But here's the problem - the progress bar never appears. The dialog comes up, but it's empty. I've spent a couple hours looking at this and have figured out that the problem definitely arises from putting the code inside the actionListener. I'm assuming it has something to do it being run as a separate thread, but I'm not sure what to do about it...

I've diluted the code I'm working on down and posted it below...and it's basically is a heavily modified version of this example.


Also probably worth noting that if I comment out dlg.setVisible(false) [line 39], the progress bar will appear after the rest of the listener completes, but at that point you can't do anything since it's a modal dialog (as it should be).

Anyone have any ideas how to make this work, or a better way of doing this? I mean I suppose I could have the dialog be static class member and just turn it on and off as needed, but that seems a strange way of doing it and not quite ideal for my project.
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
 
Brian Flowers
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Huh...I thought the actionListener already ran as a thread...guess I need to revisit some Java basics...

Anyway, that worked, thanks!
 
Why should I lose weight? They make bigger overalls. And they sure don't make overalls for tiny ads:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic