• Post Reply Bookmark Topic Watch Topic
  • New Topic

Event handling with JProgressBar  RSS feed

 
Shubham Semwal
Ranch Hand
Posts: 176
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I implement event handling with JProgressBar which is set at intermediate state.


I want to show JOptionPane message once some processing(5 seconds) is complete. But I'm not able to fire an event.
 
Les Morgan
Rancher
Posts: 767
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
right there you have that "how to implement", would you like to explain what you mean? Basically have already implemented the "Event Handler" what you have to put in there now is what you want to happen--simple as that.
 
Shubham Semwal
Ranch Hand
Posts: 176
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing is happening. Event Object is not generated and I don't know how to use events on this code. I'm unable to generate event object
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm confused. You've got a JProgressBar, and you want it to listen to events from itself? What events could those possibly be?
 
Shubham Semwal
Ranch Hand
Posts: 176
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:I'm confused. You've got a JProgressBar, and you want it to listen to events from itself? What events could those possibly be?

Initially I wanted to create an event once a counter(for-loop) reaches 100. But I couldn't do it. Now I'm trying to trigger event when I change intermediate state to false.
Basically I just want to fire any event to know the working.
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still confused. These events are supposed to happen... when? And what is supposed to send them? And what is supposed to receive them? And what is that thing supposed to do when it receives an event?

At least I'm a little less confused now that I realized that when you said "intermediate state" you were referring to the indeterminate mode of JProgressBar.

You wrote:

I want to show JOptionPane message once some processing(5 seconds) is complete.


Okay. But you don't need a JProgressBar to do that, so I don't understand why you have one.
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wait a minute:

Shubham Semwal wrote:I want to show JOptionPane message once some processing(5 seconds) is complete. But I'm not able to fire an event.


Let's just take this as a starting point. In Swing if you want something to happen after a certain delay, you use a Swing Timer. You give it a delay time and an ActionListener, which are two of the three things mentioned in your requirement. Here's a link to its tutorial: How to Use Swing Timers.
 
Shubham Semwal
Ranch Hand
Posts: 176
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Let's just take this as a starting point. In Swing if you want something to happen after a certain delay, you use a Swing Timer.


Thanks @paul. My system is out for maintenance as soon as I'll get it back I'll start posting further updates.

Initially I used action event with a JProgressBar which shows an action like loading in applications. I was ale to file an even once the task(loading completes). I was checking for (bar.getValue() == 100).
I tried to do same thing with a bar set in "indeterminate state" but wasn't able to do that.

Paul Clapham wrote:At least I'm a little less confused now that I realized that when you said "intermediate state" you were referring to the indeterminate mode of JProgressBar.


Lol sorry for that. Didn't realized
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!