List of usage examples for javax.swing JProgressBar setValue
@BeanProperty(bound = false, preferred = true, description = "The progress bar's current value.") public void setValue(int n)
From source file:Main.java
private static JProgressBar createBar() { JProgressBar progressBar = new JProgressBar(0, 100); progressBar.setValue(50); return progressBar; }
From source file:Main.java
/** * @return// w w w. ja va 2s . c o m */ private static JProgressBar createProgressBar() { JProgressBar progressBar = new JProgressBar(); progressBar.setIndeterminate(true); progressBar.setIndeterminate(false); progressBar.setMaximum(100); progressBar.setValue(100); return progressBar; }
From source file:de.uka.ilkd.key.dl.gui.initialdialog.gui.ToolInstaller.java
/** * @param tmp/*from w w w. j ava2 s . c o m*/ * @param * @throws FileNotFoundException * @throws IOException */ private static void unzip(File file, File dir, PropertySetter ps, JProgressBar bar) throws FileNotFoundException, IOException { final int BUFFER = 2048; BufferedOutputStream dest = null; FileInputStream fis = new FileInputStream(file); ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis)); ZipEntry entry; int value = 0; while ((entry = zis.getNextEntry()) != null) { bar.setValue(value++); int count; byte data[] = new byte[BUFFER]; // write the files to the disk String outputFile = dir.getAbsolutePath() + File.separator + entry.getName(); if (entry.isDirectory()) { new File(outputFile).mkdirs(); } else { FileOutputStream fos = new FileOutputStream(outputFile); dest = new BufferedOutputStream(fos, BUFFER); while ((count = zis.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, count); } dest.flush(); dest.close(); File oFile = new File(outputFile); if (OSInfosDefault.INSTANCE.getOs() == OperatingSystem.OSX) { // FIXME: we need to make everything executable as somehow // the executable bit is not preserved in // OSX oFile.setExecutable(true); } if (ps.filterFilename(oFile)) { ps.setProperty(outputFile); } } } zis.close(); file.delete(); }
From source file:net.redstonelamp.gui.RedstoneLampGUI.java
private static void installCallback(JFrame frame, File selected) { JDialog dialog = new JDialog(frame); JLabel status = new JLabel("Downloading build..."); JProgressBar progress = new JProgressBar(); dialog.pack();// www. jav a 2s. c o m dialog.setVisible(true); try { URL url = new URL("http://download.redstonelamp.net/?file=LatestBuild"); InputStream is = url.openStream(); int size = is.available(); progress.setMinimum(0); progress.setMaximum(size); int size2 = size; OutputStream os = new FileOutputStream(new File(selected, "RedstoneLamp.jar")); while (size2 > 0) { int length = Math.min(4096, size2); byte[] buffer = new byte[length]; size2 -= length; is.read(buffer); progress.setValue(size2); os.write(buffer); } is.close(); os.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:SplashScreenTest.java
/** * This method displays a frame with the same image as the splash screen. */// w ww. j a v a 2 s. c o 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:Main.java
public Main() { super(new BorderLayout()); JProgressBar progressBar = new JProgressBar(0, 100); progressBar.setValue(0); progressBar.setStringPainted(true);/* w ww. java2 s . com*/ taskOutput = new JTextArea(5, 20); taskOutput.setEditable(false); startButton = new JButton("Start"); startButton.setActionCommand("start"); startButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { startButton.setEnabled(false); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); final Task task = new Task(); task.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent pce) { if ("progress".equals(pce.getPropertyName())) { int progress = (Integer) pce.getNewValue(); progressBar.setValue(progress); taskOutput.append(String.format("Completed %d%% of task.\n", task.getProgress())); } } }); task.execute(); } }); JPanel panel = new JPanel(); panel.add(startButton); panel.add(progressBar); add(panel, BorderLayout.PAGE_START); add(new JScrollPane(taskOutput), BorderLayout.CENTER); }
From source file:de.uka.ilkd.key.dl.gui.initialdialog.gui.ToolInstaller.java
/** * @param tmp//from w w w . j av a2s . com * @param dir * @throws IOException * @throws ArchiveException */ private static void untar(File file, File dir, FileType ft, PropertySetter ps, JProgressBar bar) throws IOException, ArchiveException { FileInputStream fis = new FileInputStream(file); InputStream is; switch (ft) { case TARGZ: is = new GZIPInputStream(fis); break; case TARBZ2: is = new BZip2CompressorInputStream(fis); break; default: throw new IllegalArgumentException("Don't know how to handle filetype: " + ft); } final TarArchiveInputStream debInputStream = (TarArchiveInputStream) new ArchiveStreamFactory() .createArchiveInputStream("tar", is); TarArchiveEntry entry = null; int value = 0; while ((entry = (TarArchiveEntry) debInputStream.getNextEntry()) != null) { bar.setValue(value++); final File outputFile = new File(dir, entry.getName()); if (entry.isDirectory()) { if (!outputFile.exists()) { if (!outputFile.mkdirs()) { throw new IllegalStateException( String.format("Couldn't create directory %s.", outputFile.getAbsolutePath())); } } } else { final OutputStream outputFileStream = new FileOutputStream(outputFile); IOUtils.copy(debInputStream, outputFileStream); if (OSInfosDefault.INSTANCE.getOs() == OperatingSystem.OSX) { // FIXME: we need to make everything executable as somehow // the executable bit is not preserved in // OSX outputFile.setExecutable(true); } if (ps.filterFilename(outputFile)) { ps.setProperty(outputFile.getAbsolutePath()); } outputFileStream.flush(); outputFileStream.close(); } } debInputStream.close(); is.close(); file.delete(); }
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 w w w . j ava2s . co m return openPortBar; }
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 www . j a v a 2s . 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(); }
From source file:com.ecrimebureau.File.Hash.java
public Hash(JInternalFrame jInternalFrame, JTextArea jTA, String alg, JProgressBar jProgressBar) { this.jTA = jTA; this.algorithim = alg; this.path = path; this.jProgressBar = jProgressBar; jProgressBar.setStringPainted(true); this.jInternalFrame = jInternalFrame; jProgressBar.setMinimum(0);//w w w.ja v a2 s . co m jProgressBar.setValue(jProgressBar.getMinimum()); // }