Example usage for javax.swing JProgressBar setName

List of usage examples for javax.swing JProgressBar setName

Introduction

In this page you can find the example usage for javax.swing JProgressBar setName.

Prototype

public void setName(String name) 

Source Link

Document

Sets the name of the component to the specified string.

Usage

From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java

/**
 * @param min//from  w w w.jav a 2  s.c o m
 * @param max
 * @param paintString - true if the progress bar should display string description of progress
 * @param itemName - string description will be: "itemName x of max" (using English resource).
 * 
 * Initializes progress bar for upload actions. If min and max = 0, sets progress bar is
 * indeterminate.
 */
protected void initProgressBar(final int min, final int max, final boolean paintString, final String itemName,
        final boolean useAppProgress) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            if (!useAppStatBar && mainPanel == null) {
                log.error("UI does not exist.");
                return;
            }
            minProgVal = min;
            maxProgVal = max;
            indeterminateProgress = minProgVal == 0 && maxProgVal == 0;
            useAppStatBar = useAppProgress;
            if (useAppStatBar) {
                if (indeterminateProgress) {
                    UIRegistry.getStatusBar().setIndeterminate("UPLOADER", indeterminateProgress);
                } else {
                    UIRegistry.getStatusBar().setProgressRange("UPLOADER", minProgVal, maxProgVal);
                }
            } else {
                JProgressBar pb = mainPanel.getCurrOpProgress();
                pb.setVisible(true);
                if (indeterminateProgress) {
                    pb.setIndeterminate(true);
                    pb.setString("");
                } else {
                    if (pb.isIndeterminate()) {
                        pb.setIndeterminate(false);
                    }
                    pb.setStringPainted(paintString);
                    if (paintString) {
                        pb.setName(itemName);
                    }
                    pb.setMinimum(minProgVal);
                    pb.setMaximum(maxProgVal);
                    pb.setValue(minProgVal);
                }
            }
        }
    });
}