Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where's my ProgressMonitor content?

 
Bob Dobalina
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

A little help please... I'm kinda stuck.
I've got a Swing application running in a JFrame that allows a user to select some content from a data source, then click a button to extract the data. The extraction can take a few minutes, so I want to put up a progress bar. I already used a ProgressMonitor to display the application's status as it loads, and it displays fine, but when I try to create a new ProgressMonitor to show the status of the extraction, it doesn't draw correctly. The window shows up, and I can select it and drag it, but there's no content in the window! It's just a gray box...
I thought "Ok, this ProgressMonitor class must suck, I'll write my own damn one." So I did, based around a JDialog, and used one to display the progress of the application as it loads, and it works like a 'beaut. Then I tried the same thing during the extraction process, and none of the components I added to the dialog show up! Again, just another gray box...
Anybody have any ideas? I'm stumped...
-tim
 
Javaoops
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check with URL - Progress Bar
http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html
 
Bob Dobalina
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks for the link, but I've already read that page and there's not much to help me there, except that I can't re-use a ProgressMonitor, something that I had initially tried to do, but changed my code later to remove.
Anybody else have any ideas?
thanks,
-tim
 
Micah Wedemeyer
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I too have had some crazy problems with JProgressMonitor. I have one that pops up sometimes and stays invisible other times. There seems to be no determining when it will decide to display. If anyone has any knowledge about this, I'd be happy to hear it.
Micah
 
Bob Dobalina
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I think my problem was due to the process that I was trying to monitor. It was very system intensive and wasn't something that I could put in a thread and have pause every now and again... so it basically just chugged along and killed my app until it was done...
Micah, have you tried setting these methods?
monitor.setMillisToDecideToPopup(0);
monitor.setMillisToPopup(0);
That might just force it to pop up when you want it to, and not when it wants to...
-tim
 
Bob Dobalina
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In the off chance anyone still cares... I've got it (mostly) working. The solution is kinda convoluted, but it works.
Basically, I had to take the process of exporting the various files, and encapsulate the entire thing into a separate object, which uses a SwingWorker, which just creates an instance of an internal, private class that does the actual exporting of all the docs.
On the Swing side of things, I created a timer to regularly check the progress of the other class I created, and inside that timer I update the ProgressMonitor's note, progress, etc.
This works, but now I'm having a new problem with the ProgressMonitor. When it initially displays it doesn't have room for the "note" label. It then adds the label, shifting the Cancel button down so that only half of it is visible. This happens regardless of whether I construct it like this:
gPM = new ProgressMonitor(gFrame, "Message", "Note", 0, (size * 10));
or like this:
gPM = new ProgressMonitor(gFrame, "Message", "", 0, (size * 10));
gPM.setNote("Note");
Anybody have any ideas?
-tim
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic