uk.org.retep.util.monitor
Class JProgressBarListener

java.lang.Object
  extended by uk.org.retep.util.monitor.JProgressBarListener
All Implemented Interfaces:
ProgressListener

public class JProgressBarListener
extends java.lang.Object
implements ProgressListener

A ProgressListener that can update progress on one or two JProgressBar component(s), depending on the action being monitored.

When an update is performed, this class ensures that the updates to the JProgressBar's are done from within the Swing event thread as the process being monitored is most likely being run from another Thread.

Author:
peter

Constructor Summary
JProgressBarListener(javax.swing.JProgressBar component)
          Construct a ProgressListener with a single JProgressBar to update.
JProgressBarListener(javax.swing.JProgressBar component, javax.swing.JProgressBar secondaryComponent)
          Construct a ProgressListener with two JProgressBar's to update.
 
Method Summary
 javax.swing.JProgressBar getComponent()
           
 javax.swing.JProgressBar getSecondaryComponent()
           
 void setMaximum(long maximum)
          Notify the listeners that the maximum value has changed
 void setMaximum(long inputMaximum, long outputMaximum)
          Notify the listeners that the maximum value has changed
 void showProgress(int progress)
          Notify listeners of the current progress.
 void showProgress(long inputSize, long outputSize)
          Notify listners of the current progress.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JProgressBarListener

public JProgressBarListener(javax.swing.JProgressBar component)
Construct a ProgressListener with a single JProgressBar to update.

This component must be used from within the Swing Event Thread

Parameters:
component - JProgressBar to update

JProgressBarListener

public JProgressBarListener(javax.swing.JProgressBar component,
                            javax.swing.JProgressBar secondaryComponent)
Construct a ProgressListener with two JProgressBar's to update.

This component must be used from within the Swing Event Thread

Parameters:
component - JProgressBar to update when the input changes, null for none
secondaryComponent - JProgressBar to update when the output changes, null for none
Throws:
java.lang.IllegalArgumentException - if both component and secondaryComponent are null
Method Detail

getComponent

public javax.swing.JProgressBar getComponent()

getSecondaryComponent

public javax.swing.JProgressBar getSecondaryComponent()

showProgress

@DispatchThread(invocationType=INVOKE_LATER)
public void showProgress(int progress)
Description copied from interface: ProgressListener
Notify listeners of the current progress.

Specified by:
showProgress in interface ProgressListener
Parameters:
progress - The current value of the process

showProgress

@DispatchThread(invocationType=INVOKE_LATER)
public void showProgress(long inputSize,
                                                                  long outputSize)
Description copied from interface: ProgressListener
Notify listners of the current progress. This method is normall used by compression routines so the listener knows how much the input has been compressed by

Specified by:
showProgress in interface ProgressListener
Parameters:
inputSize - The current size of the input, possibly the amount read so far
outputSize - The current size of the output, probably the total size of the compressed output

setMaximum

@DispatchThread(invocationType=INVOKE_IMMEDIATE)
public void setMaximum(long maximum)
Description copied from interface: ProgressListener
Notify the listeners that the maximum value has changed

Specified by:
setMaximum in interface ProgressListener
Parameters:
maximum - The new maximum

setMaximum

@DispatchThread(invocationType=INVOKE_IMMEDIATE)
public void setMaximum(long inputMaximum,
                                                                    long outputMaximum)
Description copied from interface: ProgressListener
Notify the listeners that the maximum value has changed

Specified by:
setMaximum in interface ProgressListener
Parameters:
inputMaximum - The new maximum for the input
outputMaximum - The new maximum for the output.


Copyright © 1998-2010 Retep Development Group. All Rights Reserved.