List of usage examples for javax.swing JProgressBar getMaximum
public int getMaximum()
BoundedRangeModel
. From source file:Main.java
public static void main(String[] argv) throws Exception { int minimum = 0; int maximum = 100; JProgressBar progress = new JProgressBar(minimum, maximum); progress.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { JProgressBar comp = (JProgressBar) evt.getSource(); int value = comp.getValue(); int min = comp.getMinimum(); int max = comp.getMaximum(); }/*from w ww . j a va 2 s .co m*/ }); }
From source file:Main.java
public static void main(String[] argv) throws Exception { int minimum = 0; int maximum = 100; JProgressBar progress = new JProgressBar(minimum, maximum); // Get the current value int value = progress.getValue(); // Get the minimum value int min = progress.getMinimum(); // Get the maximum value int max = progress.getMaximum(); // Change the minimum value int newMin = 0; progress.setMinimum(newMin);// w w w . ja v a 2s. co m // Change the maximum value int newMax = 256; progress.setMaximum(newMax); // Set the value; the new value will be forced into the bar's range int newValue = 33; progress.setValue(newValue); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java
/** * @param val/*from www.jav a2s. co m*/ * * Sets progress bar progress. */ protected void setCurrentOpProgress(final int val) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (mainPanel == null && !useAppStatBar) { log.error("UI does not exist."); return; } if (!indeterminateProgress) { if (useAppStatBar && !indeterminateProgress) { if (val == -1) { UIRegistry.getStatusBar().incrementValue("UPLOADER"); } else { UIRegistry.getStatusBar().setValue("UPLOADER", val); } } else { JProgressBar pb = mainPanel.getCurrOpProgress(); int newVal = val == -1 ? Math.min(pb.getValue() + 1, pb.getMaximum()) : val; pb.setValue(newVal); if (pb.isStringPainted()) { pb.setString(String.format(getResourceString("WB_UPLOAD_PROGRESSBAR_TEXT"), new Object[] { pb.getName(), Integer.toString(newVal), Integer.toString(pb.getMaximum()) })); } } } } }); }
From source file:org.gofleet.module.routing.RoutingMap.java
private void newPlan(LatLon from) { JDialog d = new JDialog(basicWindow.getFrame(), "Generating New Plan"); try {/*from w w w . j a v a2 s . c o m*/ JFileChooser fc = new JFileChooser(); fc.addChoosableFileFilter(new RoutingFilter()); fc.setAcceptAllFileFilterUsed(true); int returnVal = fc.showOpenDialog(basicWindow.getFrame()); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); log.debug("Opening: " + file.getName()); JProgressBar progressBar = new JProgressBar(0, getNumberLines(file) * 2); progressBar.setValue(0); progressBar.setPreferredSize(new Dimension(150, 50)); progressBar.setStringPainted(true); d.add(progressBar); d.pack(); d.setVisible(true); TSPPlan[] param = processFile(file, progressBar); Map<String, String> values = getValues(from); double[] origin = new double[2]; origin[0] = new Double(values.get("origin_x")); origin[1] = new Double(values.get("origin_y")); TSPPlan[] res = calculateRouteOnWS(new Integer(values.get("maxDistance")), new Integer(values.get("maxTime")), origin, new Integer(values.get("startTime")), param, new Integer(values.get("timeSpentOnStop"))); progressBar.setValue(progressBar.getMaximum() - res.length); processTSPPlan(res, progressBar); } else { log.trace("Open command cancelled by user."); } } catch (Throwable t) { log.error("Error computing new plan", t); JOptionPane.showMessageDialog(basicWindow.getFrame(), "<html><p>" + i18n.getString("Main.Error") + ":</p><p>" + t.toString() + "</p><html>", i18n.getString("Main.Error"), JOptionPane.ERROR_MESSAGE); } finally { d.setVisible(false); d.dispose(); } }