Example usage for javax.swing JProgressBar JProgressBar

List of usage examples for javax.swing JProgressBar JProgressBar

Introduction

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

Prototype

public JProgressBar() 

Source Link

Document

Creates a horizontal progress bar that displays a border but no progress string.

Usage

From source file:edu.harvard.mcz.imagecapture.ui.ProgressBarRenderer.java

public ProgressBarRenderer() {
    progressBar = new JProgressBar();
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopProgressBar.java

public DesktopProgressBar() {
    impl = new JProgressBar();
    impl.setMinimum(0);
    impl.setMaximum(WHOLE_PROGRESS);
}

From source file:SplashScreenTest.java

/**
 * This method displays a frame with the same image as the splash screen.
 *///from w  w w. ja v  a  2s.  co m
private static void init2() {
    final Image img = Toolkit.getDefaultToolkit().getImage(splash.getImageURL());

    final JFrame splashFrame = new JFrame();
    splashFrame.setUndecorated(true);

    final JPanel splashPanel = new JPanel() {
        public void paintComponent(Graphics g) {
            g.drawImage(img, 0, 0, null);
        }
    };

    final JProgressBar progressBar = new JProgressBar();
    progressBar.setStringPainted(true);
    splashPanel.setLayout(new BorderLayout());
    splashPanel.add(progressBar, BorderLayout.SOUTH);

    splashFrame.add(splashPanel);
    splashFrame.setBounds(splash.getBounds());
    splashFrame.setVisible(true);

    new SwingWorker<Void, Integer>() {
        protected Void doInBackground() throws Exception {
            try {
                for (int i = 0; i <= 100; i++) {
                    publish(i);
                    Thread.sleep(100);
                }
            } catch (InterruptedException e) {
            }
            return null;
        }

        protected void process(List<Integer> chunks) {
            for (Integer chunk : chunks) {
                progressBar.setString("Loading module " + chunk);
                progressBar.setValue(chunk);
                splashPanel.repaint(); // because img is loaded asynchronously
            }
        }

        protected void done() {
            splashFrame.setVisible(false);

            JFrame frame = new JFrame();
            frame.setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setTitle("SplashScreenTest");
            frame.setVisible(true);
        }
    }.execute();
}

From source file:de.tbuchloh.kiskis.gui.widgets.PasswordQualityBar.java

/**
 * Standardkonstruktor//  w w  w.  j  a va 2s  .com
 */
public PasswordQualityBar() {
    super();
    this.setLayout(new BorderLayout());

    _progressBar = new JProgressBar();
    _progressBar.setString(DEF_MESSAGE);
    _progressBar.setBorderPainted(false);
    _progressBar.setStringPainted(true);
    _progressBar.setMaximum(128);

    add(_progressBar, BorderLayout.CENTER);
}

From source file:org.duracloud.syncui.SyncUIDriver.java

/**
 * Note: The embedded Jetty server setup below is based on the example configuration in the Eclipse documentation:
 * https://www.eclipse.org/jetty/documentation/9.4.x/embedded-examples.html#embedded-webapp-jsp
 *///from   ww  w . j  a  v  a 2  s. c  o  m
private static void launchServer(final String url, final CloseableHttpClient client) {
    try {
        final JDialog dialog = new JDialog();
        dialog.setSize(new java.awt.Dimension(400, 75));
        dialog.setModalityType(ModalityType.MODELESS);
        dialog.setTitle("DuraCloud Sync");
        dialog.setLocationRelativeTo(null);

        JPanel panel = new JPanel();
        final JLabel label = new JLabel("Loading...");
        final JProgressBar progress = new JProgressBar();
        progress.setStringPainted(true);

        panel.add(label);
        panel.add(progress);
        dialog.add(panel);
        dialog.setVisible(true);

        port = SyncUIConfig.getPort();
        contextPath = SyncUIConfig.getContextPath();
        Server srv = new Server(port);

        // Setup JMX
        MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
        srv.addBean(mbContainer);

        ProtectionDomain protectionDomain = org.duracloud.syncui.SyncUIDriver.class.getProtectionDomain();
        String warFile = protectionDomain.getCodeSource().getLocation().toExternalForm();

        log.debug("warfile: {}", warFile);
        WebAppContext context = new WebAppContext();
        context.setContextPath(contextPath);
        context.setWar(warFile);
        context.setExtractWAR(Boolean.TRUE);

        Configuration.ClassList classlist = Configuration.ClassList.setServerDefault(srv);
        classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration",
                "org.eclipse.jetty.annotations.AnnotationConfiguration");

        context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
                ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$");

        srv.setHandler(context);

        new Thread(new Runnable() {
            @Override
            public void run() {
                createSysTray(url, srv);

                while (true) {
                    if (progress.getValue() < 100) {
                        progress.setValue(progress.getValue() + 3);
                    }

                    sleep(2000);
                    if (isAppRunning(url, client)) {
                        break;
                    }
                }

                progress.setValue(100);

                label.setText("Launching browser...");
                launchBrowser(url);
                dialog.setVisible(false);
            }
        }).start();

        srv.start();

        srv.join();
    } catch (Exception e) {
        log.error("Error launching server: " + e.getMessage(), e);
    }
}

From source file:com.github.boogey.progressview.swing.JProgressPanel.java

/**
 * Initialize the attributes of this classes. This method will be called in the constructor of this class.
 *//*from  w ww .  j a va2 s  . co  m*/
protected void initObjects() {
    setLayout(new GridBagLayout());
    progressBar = new JProgressBar();
    messageLabel = new JLabel();
    positionElements();
}

From source file:ProgressDialog.java

private void setupControls() {

    progressBar = new JProgressBar();
    Dimension preferredSize = progressBar.getPreferredSize();
    preferredSize.width = PROGRESS_BAR_WIDTH;
    progressBar.setPreferredSize(preferredSize);
    lblMessage = new JLabel(" ");
}

From source file:de.atomfrede.tools.evalutation.evaluator.AbstractEvaluator.java

/**
 * //from  w  w  w.jav  a2  s  .  co  m
 * @param outputFolderName
 */
public AbstractEvaluator(String outputFolderName) {
    // creating progressbar
    progressBar = new JProgressBar();
    // paint the value in percent for this progress
    progressBar.setStringPainted(true);

    try {
        if (!outputRootFolder.exists()) {
            outputFolder.mkdir();
        }
        if (!inputRootFolder.exists())
            throw new RuntimeException("No input folder avaliable!");

        outputFolder = new File(outputRootFolder, outputFolderName);
        if (!outputFolder.exists())
            outputFolder.mkdir();
    } catch (Exception ioe) {
        throw new RuntimeException("Outputfolder could not be created!");
    }
}

From source file:edu.ku.brc.ui.ProgressFrame.java

/**
 * @param title//from  ww  w.  ja v a2  s  .c o  m
 * @param iconName
 */
protected void createUI(final String title, final String iconName) {
    PanelBuilder builder = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p,5px,p,5px,p,10px,p"));
    CellConstraints cc = new CellConstraints();

    overallProgress = new JProgressBar();
    processProgress = new JProgressBar();
    desc = createLabel("");
    closeBtn = createButton("Cancel");

    processProgress.setStringPainted(true);
    overallProgress.setStringPainted(true);

    desc.setHorizontalAlignment(SwingConstants.CENTER);
    builder.add(desc, cc.xywh(1, 1, 3, 1));

    builder.add(createLabel("Process:"), cc.xy(1, 3)); // I18N
    builder.add(processProgress, cc.xy(3, 3));

    builder.add(overallLbl = createLabel("Overall:"), cc.xy(1, 5)); // I18N
    builder.add(overallProgress, cc.xy(3, 5));

    builder.add(closeBtn, cc.xy(1, 7));

    builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JPanel mainPanel = new JPanel(new BorderLayout());
    if (StringUtils.isNotEmpty(iconName)) {
        PanelBuilder iconBldr = new PanelBuilder(
                new FormLayout("8px, f:p:g,130px,f:p:g", "8px,f:p:g,130px,f:p:g, 8px"));
        iconBldr.add(new JLabel(IconManager.getIcon(iconName)), cc.xy(3, 3));
        mainPanel.add(iconBldr.getPanel(), BorderLayout.WEST);
        mainPanel.add(builder.getPanel(), BorderLayout.CENTER);

    } else {
        mainPanel = builder.getPanel();
    }

    setContentPane(mainPanel);

    setSize(new Dimension(500, 125));

    setTitle(title);

    overallProgress.setIndeterminate(true);

    instance = this;
    closeBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            instance.setVisible(false);
            System.exit(0);
        }
    });

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    ImageIcon appIcon = IconManager.getIcon("AppIcon"); //$NON-NLS-1$
    if (appIcon != null) {
        setIconImage(appIcon.getImage());
    }

    pack();
}

From source file:com.swg.parse.docx.OpenFolderAction.java

@Override
public void actionPerformed(ActionEvent e) {

    JFileChooser fc = new JFileChooser();
    fc.setCurrentDirectory(new File("C:/"));
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    if (selectedFile != null) {
        fc.setSelectedFile(selectedFile);
    }/*from  w  w w . j  av a  2  s .c  o m*/

    int returnVal = fc.showDialog(WindowManager.getDefault().getMainWindow(), "Extract Data");

    JFrame jf = new JFrame("Progress Bar");
    Container Jcontent = jf.getContentPane();
    JProgressBar progressBar = new JProgressBar();
    progressBar.setValue(0);
    progressBar.setStringPainted(true);
    Jcontent.add(progressBar, BorderLayout.NORTH);
    jf.setSize(300, 60);
    jf.setVisible(true);

    //we needed a new thread for a functional progress bar on the JFrame
    new Thread(new Runnable() {
        public void run() {

            if (returnVal == JFileChooser.APPROVE_OPTION) {

                File file = fc.getSelectedFile();
                selectedFile = file;

                FileFilter fileFilter = new WildcardFileFilter("*.docx");
                File[] files = selectedFile.listFiles(fileFilter);
                double cnt = 0, cnt2 = 0; //number of how many .docx is in the folder
                for (File f : files) {
                    if (!f.getAbsolutePath().contains("~"))
                        cnt2++;
                }

                for (File f : files) {
                    cnt++;
                    pathToTxtFile = f.getAbsolutePath().replace(".docx", ".txt");
                    TxtFile = new File(pathToTxtFile);

                    //----------------------------------------------------
                    String zipFilePath = "C:\\Users\\fja2\\Desktop\\junk\\Test\\test.zip";
                    String destDirectory = "C:\\Users\\fja2\\Desktop\\junk\\Test " + cnt;
                    UnzipUtility unzipper = new UnzipUtility();
                    try {
                        File zip = new File(zipFilePath);
                        File directory = new File(destDirectory);
                        FileUtils.copyFile(f, zip);
                        unzipper.UnzipUtility(zip, directory);

                        zip.delete();

                        String mediaPath = destDirectory + "/word/media/";
                        File mediaDir = new File(mediaPath);

                        for (File fil : mediaDir.listFiles()) {
                            FileUtils.copyFile(fil, new File("C:\\Users\\PXT1\\Desktop\\test\\Pictures\\"
                                    + f.getName() + "\\" + fil.getName()));
                        }

                        FileUtils.deleteDirectory(directory);

                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                    //----------------------------------------------------

                    //if the txt file doesn't exist, it tries to convert whatever 
                    //can be the txt into the actual txt.
                    if (!TxtFile.exists()) {
                        pathToTxtFile = f.getAbsolutePath().replace(".docx", "");
                        TxtFile = new File(pathToTxtFile);
                        pathToTxtFile += ".txt";
                        TxtFile.renameTo(new File(pathToTxtFile));
                        TxtFile = new File(pathToTxtFile);
                    }

                    String content = "";
                    String POIContent = "";

                    try {
                        content = readTxtFile();
                        version = DetermineVersion(content);
                        NewExtract ext = new NewExtract();
                        ext.extract(content, f.getAbsolutePath(), version, (int) cnt);

                    } catch (FileNotFoundException ex) {
                        Exceptions.printStackTrace(ex);
                    } catch (IOException ex) {
                        Exceptions.printStackTrace(ex);
                    } catch (ParseException ex) {
                        Exceptions.printStackTrace(ex);
                    }

                    double tempProg = (cnt / cnt2) * 100;
                    progressBar.setValue((int) tempProg);
                    System.gc();
                }

            } else {
                //do nothing
            }
        }
    }).start();

    System.gc();

}