List of usage examples for javax.swing JProgressBar setString
@BeanProperty(visualUpdate = true, description = "Specifies the progress string to paint") public void setString(String s)
From source file:Main.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("ProgressBars"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JProgressBar dJProgressBar = new JProgressBar(); dJProgressBar.setValue(100);/* www. j av a 2s . co m*/ dJProgressBar.setBorderPainted(false); dJProgressBar.setString("Ack"); dJProgressBar.setStringPainted(true); frame.add(dJProgressBar, BorderLayout.WEST); frame.setSize(300, 200); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("ProgressBars"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JProgressBar dJProgressBar = new JProgressBar(JProgressBar.VERTICAL); dJProgressBar.setValue(100);/*from w w w. java 2s. c om*/ dJProgressBar.setBorderPainted(false); dJProgressBar.setString("Ack"); dJProgressBar.setStringPainted(true); frame.add(dJProgressBar, BorderLayout.WEST); frame.setSize(300, 200); frame.setVisible(true); }
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.setOrientation(SwingConstants.HORIZONTAL); int newValue = 33; progress.setValue(newValue);// w w w . j a va 2 s . com progress.setString("value"); System.out.println(progress.getString()); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JProgressBar bar = new JProgressBar(JProgressBar.VERTICAL); bar.setEnabled(true);/*www . ja va2 s. c om*/ bar.setBackground(Color.YELLOW); bar.setForeground(Color.GREEN); bar.setStringPainted(true); bar.setString("2000 g"); bar.setValue(65); frame.setLayout(new BorderLayout()); frame.add(bar, BorderLayout.CENTER); frame.setSize(500, 400); frame.setVisible(true); }
From source file:SplashScreenTest.java
/** * This method displays a frame with the same image as the splash screen. */// w w w . j a v a2s.c om 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:com.roche.iceboar.progressview.ProgressUpdater.java
public ProgressUpdater(JProgressBar progressBar, JLabel messageLabel, ProgressEventFactory progressEventFactory) { this.progressBar = progressBar; this.messageLabel = messageLabel; this.events = new HashSet<ProgressEvent>(progressEventFactory.getAllProgressEvents()); amountOfEvents = events.size();/*from ww w . j ava2 s.co m*/ progressBar.setMinimum(0); progressBar.setMaximum(amountOfEvents); progressBar.setValue(0); progressBar.setString("0 %"); }
From source file:com.moss.appprocs.swing.ProgressMonitorBean.java
private void update() { if (log.isDebugEnabled()) log.debug("Updating " + process.name()); ProgressReport report = process.progressReport(); super.getLabelTaskname().setText(process.name()); super.getLabelDescription().setText(process.description()); final JProgressBar pBar = getProgressBar(); String string = report.accept(new ProgressReportVisitor<String>() { public String visit(BasicProgressReport r) { getCommandButton().setEnabled(false); pBar.setIndeterminate(true); return r.describe() + "..."; }//w ww. ja v a 2s. co m public String visit(TrackableProgressReport t) { pBar.setIndeterminate(false); pBar.setMinimum(0); pBar.setMaximum((int) t.length()); pBar.setValue((int) t.progress()); return t.describe(); } }); if (process.state() == State.STOPPABLE) { stopButton().setEnabled(true); } else { stopButton().setEnabled(false); } pBar.setString(string); }
From source file:UI.MainViewPanel.java
public JProgressBar getPanel7(Metric7 m7) { JProgressBar openPortBar = new JProgressBar(0, 100); openPortBar.setValue(m7.totalCriticalCount); openPortBar.setBorder(BorderFactory.createLineBorder(Color.BLACK)); UIDefaults defaults = new UIDefaults(); Painter foregroundPainter = new MyPainter(new Color(230, 219, 27)); Painter backgroundPainter = new MyPainter(chartBackgroundColor); defaults.put("ProgressBar[Enabled].foregroundPainter", foregroundPainter); defaults.put("ProgressBar[Enabled+Finished].foregroundPainter", foregroundPainter); defaults.put("ProgressBar[Enabled].backgroundPainter", backgroundPainter); openPortBar.putClientProperty("Nimbus.Overrides.InheritDefaults", Boolean.TRUE); openPortBar.putClientProperty("Nimbus.Overrides", defaults); openPortBar.setString("" + m7.totalCriticalCount); openPortBar.setStringPainted(true);/*from www . j a v a 2 s . co m*/ return openPortBar; }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java
/** * @param min/*from w ww . j a v a2 s.co 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); } } } }); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java
/** * @param val//from w w w .j ava2s .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()) })); } } } } }); }