@Override public void progressChanged(ProgressChangeEvent e) { lastState = e.getState(); if (lastState == ProgressState.Exception) { setVisible(false); } // Track state if (e.getState() == ProgressState.Start) { bar.setValue(0); if (!trackerDialog.isVisible() && !Property.DIALOGS_PROGRESS_AUTOSHOW.get()) { WindowsUtils.center(trackerDialog); setVisible(true); } } if (e.getState() == ProgressState.Stop) { setVisible(false); } if (e.getValue() != null) { if (e.getPercents() != null) { bar.setValue(e.getPercents()); bar.setIndeterminate(false); bar.setString(null); } else { bar.setIndeterminate(true); bar.setString(SynchronizationUtils.makeSizeString(e)); } } if (e.getText() != null) { bar.setToolTipText(e.getText()); } }
public JDialog showProgressDialog( JDialog parent, String title, String message, boolean includeCancelButton) { fileSearchCancelled = false; final JDialog prog; JProgressBar bar = new JProgressBar(SwingConstants.HORIZONTAL); JButton cancel = new JButton(Globals.lang("Cancel")); cancel.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent event) { fileSearchCancelled = true; ((JButton) event.getSource()).setEnabled(false); } }); prog = new JDialog(parent, title, false); bar.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); bar.setIndeterminate(true); if (includeCancelButton) { prog.add(cancel, BorderLayout.SOUTH); } prog.add(new JLabel(message), BorderLayout.NORTH); prog.add(bar, BorderLayout.CENTER); prog.pack(); prog.setLocationRelativeTo(null); // parent); // SwingUtilities.invokeLater(new Runnable() { // public void run() { prog.setVisible(true); // } // }); return prog; }
private void startAction(boolean export) { optionsFrame.setVisible(false); progressBar.setValue(0); progressBar.setIndeterminate(true); textArea.setText(""); progressFrame.setVisible(true); new Thread(new ImportExportRunnable(export)).start(); }
@Override public void propertyChange(PropertyChangeEvent evt) { String strPropertyName = evt.getPropertyName(); if ("progress".equals(strPropertyName)) { progressBar.setIndeterminate(false); int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); } }
plzwai() { LookAndFeel lf = UIManager.getLookAndFeel(); try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); // UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); } catch (Exception e) { } fplz = new JFrame("Sending The Pay Slip. Please Wait...."); fplz.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JProgressBar aJProgressBar = new JProgressBar(JProgressBar.HORIZONTAL); // aJProgressBar.setStringPainted(true); aJProgressBar.setIndeterminate(true); fplz.add(new JPanel(), BorderLayout.NORTH); fplz.setIconImage(Toolkit.getDefaultToolkit().getImage("Bin\\img\\airindia.jpg")); fplz.add(new JPanel(), BorderLayout.WEST); fplz.add(new JPanel(), BorderLayout.EAST); fplz.add(new JPanel(), BorderLayout.SOUTH); fplz.add(aJProgressBar, BorderLayout.CENTER); fplz.setResizable(false); fplz.setLocation(h / 3, w / 4); fplz.setSize(700, 100); fplz.setVisible(true); }
protected synchronized void stopProgressRepaint() { progressWorks = false; progress.setIndeterminate(false); contentpanel.repaint(); }
protected synchronized void stopProgress() { progressWorks = false; progress.setIndeterminate(false); // TODO: ADD NOISE WERKT NIET MEER!!! updateContentPanel(); }
protected synchronized void startProgress() { progressWorks = true; progress.setIndeterminate(true); }
public ScrapeView() { this.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); GridBagLayout layout = new GridBagLayout(); this.setLayout(layout); GridBagConstraints constraint = new GridBagConstraints(); constraint.insets = new Insets(3, 3, 3, 3); constraint.weightx = 1; constraint.weighty = 0; constraint.gridwidth = 1; constraint.anchor = GridBagConstraints.CENTER; { websiteDataUrlLabel = new JLabel("Website data URL:"); constraint.weightx = 0; constraint.weighty = 0; constraint.gridx = 0; constraint.gridy = 0; constraint.gridwidth = 1; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(websiteDataUrlLabel, constraint); } { websiteDataUrlTextField = new JTextField(""); websiteDataUrlTextField .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { try { String str = e.getDocument().getText(0, e.getDocument().getLength()); if (str.contains("motel6.com")) { parserComboBox.setSelectedIndex(0); } else if (str.contains("redroof.com")) { parserComboBox.setSelectedIndex(1); } else if (str.contains("redlion.com")) { parserComboBox.setSelectedIndex(2); } } catch (BadLocationException exception) { logger.error(exception); } } @Override public void removeUpdate(DocumentEvent e) {} @Override public void changedUpdate(DocumentEvent e) {} }); constraint.weightx = 1; constraint.weighty = 0; constraint.gridx = 1; constraint.gridy = 0; constraint.gridwidth = 1; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(websiteDataUrlTextField, constraint); } { browserEngineLabel = new JLabel("Browser engine:"); constraint.weightx = 0; constraint.weighty = 0; constraint.gridx = 0; constraint.gridy = 1; constraint.gridwidth = 1; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(browserEngineLabel, constraint); } { String[] values = new String[] {"HtmlUnit", "Ui4j", "JxBrowser"}; browserEngineComboBox = new JComboBox<>(values); browserEngineComboBox.setSelectedIndex(2); constraint.weightx = 1; constraint.weighty = 0; constraint.gridx = 1; constraint.gridy = 1; constraint.gridwidth = 1; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(browserEngineComboBox, constraint); } { parserLabel = new JLabel("Website parser:"); constraint.weightx = 0; constraint.weighty = 0; constraint.gridx = 0; constraint.gridy = 2; constraint.gridwidth = 1; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(parserLabel, constraint); } { String[] values = new String[] {"Motel6", "RedRoof", "RedLion"}; parserComboBox = new JComboBox<>(values); parserComboBox.setSelectedIndex(0); constraint.weightx = 1; constraint.weighty = 0; constraint.gridx = 1; constraint.gridy = 2; constraint.gridwidth = 1; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(parserComboBox, constraint); } { scrapeButton = new JButton("Scrape website"); constraint.weightx = 1; constraint.weighty = 0; constraint.gridx = 0; constraint.gridy = 3; constraint.gridwidth = 2; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(scrapeButton, constraint); } { outputTextArea = new JTextArea(); outputTextArea.setEditable(false); outputTextArea.setWrapStyleWord(false); outputTextArea.setAutoscrolls(true); JScrollPane scrollPane = new JScrollPane(outputTextArea); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); constraint.weightx = 1; constraint.weighty = 1; constraint.gridx = 0; constraint.gridy = 4; constraint.gridwidth = 2; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(scrollPane, constraint); } { progressBar = new JProgressBar(); progressBar.setString(progressBarTextPrefix); progressBar.setStringPainted(true); progressBar.setIndeterminate(true); progressBar.setVisible(false); constraint.weightx = 1; constraint.weighty = 0; constraint.gridx = 0; constraint.gridy = 5; constraint.gridwidth = 2; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(progressBar, constraint); } }