Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  *  Copyright (c) 2011 Leibniz Institute of Plant Genetics and Crop Plant Research (IPK), Gatersleben, Germany.
  *  All rights reserved. This program and the accompanying materials
  *  are made available under the terms of the GNU Lesser Public License v2.1
  *  which accompanies this distribution, and is available at
  *  Contributors:
  *      Leibniz Institute of Plant Genetics and Crop Plant Research (IPK), Gatersleben, Germany - RMI Client, FileChooser and WebDAV
public class FileProgressMonitor {
	private int max;

Constructs a graphic object that shows progress, typically by filling in a rectangular bar as the process nears completion.

max the upper bound of the range
	public FileProgressMonitor(JProgressBar fileProgressBarint max) {
		this. = max;
		this. = fileProgressBar;

Indicate the progress of the operation being monitored. If the specified value is >= the maximum, the progress monitor is closed.

newValue an int specifying the current value, between the maximum and minimum specified for this component
	public void setProgress(final int newValue) {
		if (newValue >= ) {
else if (this. != null) {
			try {
				// if (sun.awt.AppContext.getAppContext() == null) {
				// sun.awt.SunToolkit.createNewAppContext();
				// }
				SwingUtilities.invokeAndWait(new Runnable() {
					public void run() {
						.setValue((int) Math.ceil(100.0 / 
catch (Exception e) {

Indicate that the operation is complete. This happens automatically when the value set by setProgress is >= max, but it may be called earlier if the operation ends early.
	public void close() {

Returns the maximum value -- the higher end of the progress value.

an int representing the maximum value
See also:
	public int getMaximum() {
		return ;

Specifies the maximum value.

m an int specifying the maximum value
See also:
	public void setMaximum(int m) {
		if ( != null) {
		 = m;
New to GrepCode? Check out our FAQ X