Refine search
private static void setValue(final BoundedRangeModel model, final int val) { if (SwingUtilities.isEventDispatchThread()) { model.setValue(val); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { model.setValue(val); } }); } } }
@Override protected void repaint() { if(SwingUtilities.isEventDispatchThread()) { component.repaint(); } else { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { component.repaint(); } }); } }
public void create(boolean waitFor){ if (SwingUtilities.isEventDispatchThread()) { initInEDT(); } else { try { if (waitFor) { try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { initInEDT(); } }); } catch (InterruptedException ex) { listener.handleError("Interrupted", ex); } } else { SwingUtilities.invokeLater(new Runnable() { public void run() { initInEDT(); } }); } } catch (InvocationTargetException ex) { throw new AssertionError(); // can never happen } } }
if (SwingUtilities.isEventDispatchThread()) { runnable.run(); } else { SwingUtilities.invokeLater(runnable); SwingUtilities.invokeLater(runnable); break; case SYNC: if (SwingUtilities.isEventDispatchThread()) { runnable.run(); } else { break; case OUTSIDE: if (SwingUtilities.isEventDispatchThread()) { DEFAULT_EXECUTOR_SERVICE.submit(runnable); } else {
/** Body of task executed in RequestProcessor. Runs AsyncGUIJob's worker * method and after its completion posts AsyncJob's UI update method * to AWT thread. */ @Override public void run() { if (!SwingUtilities.isEventDispatchThread()) { LOG.log(Level.FINE, "Prepare outside AWT for {0}", comp4Init); // first pass, executed in some of RP threads initJob.construct(); comp4Init.removeHierarchyListener(this); LOG.log(Level.FINE, "No hierarchy listener for {0}", comp4Init); // continue to invoke finished method only if hasn't been cancelled boolean localCancel; synchronized (CANCELLED_LOCK) { localCancel = wasCancelled; } LOG.log(Level.FINE, "wasCancelled {0}", localCancel); if (!localCancel) { SwingUtilities.invokeLater(this); } } else { // second pass, executed in event dispatch thread initJob.finished(); LOG.fine("Second pass finished"); } }
@Override public boolean showSettingsDialog(AppSettings sourceSettings, final boolean loadFromRegistry) { if (SwingUtilities.isEventDispatchThread()) { throw new IllegalStateException("Cannot run from EDT"); SwingUtilities.invokeLater(new Runnable() {
if (SwingUtilities.isEventDispatchThread()){ updateUI(); } else { SwingUtilities.invokeLater(new Runnable(){ public void run(){ updateUI();
@Override public void updateModel(final int totalSize, final int screenHeight) { if(!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() {
@Override public void showError(final String message) { if (SwingUtilities.isEventDispatchThread()) { JOptionPane.showMessageDialog(this, message, "Error", JOptionPane.ERROR_MESSAGE); } else { SwingUtilities.invokeLater(() -> JOptionPane.showMessageDialog(getFrame(), message, "Error", JOptionPane.ERROR_MESSAGE)); } }
@Override public void showMessage(final String message) { if (SwingUtilities.isEventDispatchThread()) { JOptionPane.showMessageDialog(this, message); } else { SwingUtilities.invokeLater(() -> JOptionPane.showMessageDialog(getFrame(), message)); } }
public void uncaughtException(final Thread t, final Throwable e) { if (SwingUtilities.isEventDispatchThread()) { showException(t, e); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { showException(t, e); } }); } }
/** * Subclasses may override updateState() so make sure we always call it * from EDT. */ private synchronized void _updateState() { if (SwingUtilities.isEventDispatchThread ()) { updateState(); } else { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { updateState(); } }); } }
@Override public DataContentHandler createDataContentHandler(final String maxPrefix) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { createDataContentHandler(maxPrefix); } }); return null; } ignoreEvents = true; try { searchTextField.setText(maxPrefix); } finally { ignoreEvents = false; } return null; } });
/** * Called when an uncaught exception is thrown. Will display the error message in a dialog box. * * @param t the thread where the exception was throws. * @param e the thrown exception. */ @Override public void uncaughtException(final Thread t, final Throwable e) { try { if (SwingUtilities.isEventDispatchThread()) { showException(t, e); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { showException(t, e); } }); } } catch (Exception excpt) { LOGGER.error("", excpt); } }
/** * Creates a new map frame with a toolbar, map pane and status bar; sets the supplied {@code * MapContent}; and displays the frame. If {@linkplain MapContent#getTitle()} returns a * non-empty string, this is used as the frame's title. * * <p>This method can be called safely from any thread. * * @param content the map content */ public static void showMap(final MapContent content) { if (SwingUtilities.isEventDispatchThread()) { doShowMap(content); } else { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { doShowMap(content); } }); } }
public void showErrorDialog(final String title, final String message) { if (SwingUtilities.isEventDispatchThread()) { errorDialog.showDialog(title, message); } else { SwingUtilities.invokeLater(() -> errorDialog.showDialog(title, message)); } }
/** * Displays an exception in a dialog where the title is the exception class name and the body of * the dialog shows the given message. * * <p>It is safe to call this method from any thread. * * @param exception exception to display * @param message message to display; if {@code null} or empty the message will be taken from * the exception */ public static void showDialog(final Throwable exception, final String message) { if (exception == null) { throw new IllegalArgumentException("exception must not be null"); } if (SwingUtilities.isEventDispatchThread()) { doShowDialog(exception, message); } else { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { doShowDialog(exception, message); } }); } }
private void prepareMessage(final String msg, final ImageIcon icon, final Color fgColor) { if( !SwingUtilities.isEventDispatchThread() ) { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { prepareMessage( msg, icon, fgColor ); } } ); return; } String message = msg; messagePane.setToolTipText (message); if (message != null) { message = message.replaceAll("\\s", " "); // NOI18N if (! message.toUpperCase().startsWith("<HTML>")) { // NOI18N message = "<HTML>" + message; // NOI18N } } iconLabel.setIcon(icon); iconLabel.setForeground(fgColor); messagePane.setForeground(fgColor); messagePane.setText(message); messagePane.setFocusable(message != null); }
public static Connection showDialog( final String title, final String initialText, final int flags, final int textAreaRows, final int textAreaCols) { final Connection[] conn = new Connection[1]; if (SwingUtilities.isEventDispatchThread()) { conn[0] = doShowDialog(title, initialText, flags, textAreaRows, textAreaCols); } else { final CountDownLatch latch = new CountDownLatch(1); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { conn[0] = doShowDialog( title, initialText, flags, textAreaRows, textAreaCols); latch.countDown(); } }); try { latch.await(DIALOG_CREATION_TIMEOUT, TimeUnit.MILLISECONDS); } catch (InterruptedException ex) { LOGGER.severe("Thread interrupted while setting up text reporter"); return null; } } return conn[0]; }
/** Body of task executed in RequestProcessor. Runs AsyncGUIJob's worker * method and after its completion posts AsyncJob's UI update method * to AWT thread. */ @Override public void run() { if (!SwingUtilities.isEventDispatchThread()) { LOG.log(Level.FINE, "Prepare outside AWT for {0}", comp4Init); // first pass, executed in some of RP threads initJob.construct(); comp4Init.removeHierarchyListener(this); LOG.log(Level.FINE, "No hierarchy listener for {0}", comp4Init); // continue to invoke finished method only if hasn't been cancelled boolean localCancel; synchronized (CANCELLED_LOCK) { localCancel = wasCancelled; } LOG.log(Level.FINE, "wasCancelled {0}", localCancel); if (!localCancel) { SwingUtilities.invokeLater(this); } } else { // second pass, executed in event dispatch thread initJob.finished(); LOG.fine("Second pass finished"); } }