Note that there are some explanatory texts on larger screens.

plurals
  1. POJava - ProgressBar opened after calculating
    primarykey
    data
    text
    <p>I have main file that use ProgressBar. In main file I call ProgressBar as</p> <pre><code>ProgressBar pbFrame = new ProgressBar(); pbFrame.setVisible(true); </code></pre> <p>I call ProgressBar after calling executable file "calculate.exe" to show that calculate.exe is working now. But ProgressBar opens when "calculate.exe" finished. How to make parallel executing of "calculate.exe" and ProgressBar? I hear about SwingWorker but I absolutely don't understand how to use it in my application.</p> <p>My ProgressBar file:</p> <pre><code>public class ProgressBar extends JFrame { static private int BOR = 10; private String filename; public ProgressBar() { super("Calculating progress"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createEmptyBorder(BOR, BOR, BOR, BOR)); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(new JLabel("Calculating...")); panel.add(Box.createVerticalGlue()); JProgressBar progressBar1 = new JProgressBar(); progressBar1.setIndeterminate(true); panel.add(progressBar1); panel.add(Box.createVerticalGlue()); JPanel buttonsPanel = new JPanel(); buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.Y_AXIS)); buttonsPanel.add(Box.createVerticalGlue()); JButton quitButton = new JButton("OK!"); quitButton.setHorizontalAlignment(JButton.CENTER); quitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dispose(); } }); panel.add(quitButton); getContentPane().setLayout(new BorderLayout()); getContentPane().add(panel, BorderLayout.CENTER); setPreferredSize(new Dimension(200, 110)); setLocationRelativeTo(null); pack(); } </code></pre> <p>}</p> <p>thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload