Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Cracked it!</strong> - paintImmediately() does the magic:</p> <pre><code>m_pane.setOptions(null); m_pane.setMessage("Populating..."); m_jDialog.setTitle("Table being populated..."); Rectangle rect = m_jDialog.getContentPane().getBounds(); ((JComponent)m_jDialog.getContentPane()).paintImmediately( rect ); </code></pre> <p><em><strong>later</em></strong></p> <p>for anyone stumbling on this and worried about the incoherent comment below, I think it is fair to assume this comment can be safely ignored: firstly, I see no evidence anywhere that paintImmediately is designed to execute outside the EDT, and secondly deadlock, in a concurrency sense, occurs only with a mutable object shared between two threads: thus, in a loop iteration of these chunks in the EDT this is wrong, in my opinion. </p> <p><strong>Another change to the above code</strong></p> <p>Java API for awt.Dialog.show(): "It is permissible to show modal dialogs from the event dispatching thread because the toolkit will ensure that another event pump runs while the one which invoked this method is blocked". What this means is that if DISPLAY_WAIT_FOR_TASK is the last chunk delivered to process() we are OK: another event pump runs following m_jDialog.setVisible( true ), and this new event pump handles the next call to process(). </p> <p>Conversely, if a chunk were to be coalesced with DISPLAY_WAIT_FOR_TASK (i.e. if another follows it in the same process() call), the code would block at setVisible( true ), and the loop would move on to process the next chunk only when the JOptionPane had been "disposed" by the user or programatically. </p> <p>To prevent this, and enable things to continue to run immediately after this setVisible() command, it is necessary to have the single command m_jDialog.setVisible( true ) run in its own (non-EDT) Thread (NB JOptionPane is designed to run in either the EDT or a non-EDT).</p> <p>Obviously this special Thread for the JOptionPane can be created on the spot or enlisted from an available thread pool, ExecutorService, etc.</p>
 

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