/** * Creates a new progress bar * * @param title the progress bar title * @param labelText label to display in the body of the progress bar */ public ProgressMeter(String title, String labelText) { setTitle(title); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); progBar = new JProgressBar(MIN_PROGRESS, MAX_PROGRESS); getContentPane().add(progBar, BorderLayout.CENTER); label = new JLabel(" "); if (labelText != null && labelText.length() > 0) { label.setText(labelText); } getContentPane().add(label, BorderLayout.SOUTH); setSize(400, 60); setLocationByPlatform(true); }
/** * Updates the progress label. It is safe to call this method from any thread. * * @param text the new label text */ public void setLabel(final String text) { if (!isVisible() || EventQueue.isDispatchThread()) { label.setText(text); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { label.setText(text); } }); } }
/** * Creates a new progress bar * * @param title the progress bar title * @param labelText label to display in the body of the progress bar */ public ProgressMeter(String title, String labelText) { setTitle(title); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); progBar = new JProgressBar(MIN_PROGRESS, MAX_PROGRESS); getContentPane().add(progBar, BorderLayout.CENTER); label = new JLabel(" "); if (labelText != null && labelText.length() > 0) { label.setText(labelText); } getContentPane().add(label, BorderLayout.SOUTH); setSize(400, 60); setLocationByPlatform(true); }
/** * Updates the progress label. It is safe to call this method from any thread. * * @param text the new label text */ public void setLabel(final String text) { if (!isVisible() || EventQueue.isDispatchThread()) { label.setText(text); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { label.setText(text); } }); } }
/** * Updates the progress bar. It is safe to call this method from any thread. * * @param progress a proportion value between 0 and 1 */ public void setProgress(final float progress) { final int barValue = (int)Math.ceil((MAX_PROGRESS - MIN_PROGRESS) * progress); if (isVisible()) { if (EventQueue.isDispatchThread()) { progBar.setValue(barValue); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { progBar.setValue(barValue); } }); } } else { progBar.setValue(barValue); preset = true; } }
/** * Updates the progress bar. It is safe to call this method from any thread. * * @param progress a proportion value between 0 and 1 */ public void setProgress(final float progress) { final int barValue = (int)Math.ceil((MAX_PROGRESS - MIN_PROGRESS) * progress); if (isVisible()) { if (EventQueue.isDispatchThread()) { progBar.setValue(barValue); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { progBar.setValue(barValue); } }); } } else { progBar.setValue(barValue); preset = true; } }