Example usage for javax.swing SwingUtilities isEventDispatchThread

List of usage examples for javax.swing SwingUtilities isEventDispatchThread

Introduction

In this page you can find the example usage for javax.swing SwingUtilities isEventDispatchThread.

Prototype

public static boolean isEventDispatchThread() 

Source Link

Document

Returns true if the current thread is an AWT event dispatching thread.

Usage

From source file:com.igormaznitsa.zxpoly.MainForm.java

private void updateInfoPanel() {
    if (SwingUtilities.isEventDispatchThread()) {
        infobarUpdater.run();// ww  w .ja v a 2s  . c  o  m
    } else {
        SwingUtilities.invokeLater(infobarUpdater);
    }
}

From source file:com.archivas.clienttools.arcmover.gui.panels.ProfilePanel.java

private void setPathAndFileListToHomeDirectory() {
    if (!SwingUtilities.isEventDispatchThread()) {
        String errMsg = "setPathAndFileListToHomeDirectory is not on the EDT but it should be";
        IllegalStateException ex = new IllegalStateException(errMsg);
        LOG.log(Level.SEVERE, errMsg, ex);
        throw ex;
    }//from w  w  w.ja  va2s  .  c  o m
    try {
        ProfilePanelAdapter profileAdapter = profileModel.getProfileAdapter();
        setPathAndFileListToDirectory(profileAdapter.getHomeDirectory().getPath());
    } catch (Exception e) {
        String errMsg = DBUtils.getErrorMessage("An error occurred opening home directory", e);
        GUIHelper.showMessageDialog(this, errMsg, "Error Opening Directory", JOptionPane.ERROR_MESSAGE);
        LOG.log(Level.WARNING, "An error occurred getting the home directory listing: " + e.toString(), e);
    }
}

From source file:edu.ku.brc.specify.dbsupport.BuildFromGeonames.java

private void doProgress(final int startProgress, final int endProgress, final String msg) {
    if (frame != null) {
        if (SwingUtilities.isEventDispatchThread()) {
            frame.setProcess(startProgress, endProgress);
            frame.setDesc(msg);//from  www .  j  a  va 2  s  .  com

        } else {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    frame.setProcess(startProgress, endProgress);
                    frame.setDesc(msg);
                }
            });
        }
    }
}

From source file:com.aw.swing.mvp.binding.component.BndSJTable.java

/**
 * Update the row in the jtable//from   w w w.ja va  2s . c  o  m
 *
 * @param index
 * @param row
 */
public void updateRow(final int index, final Object row) {
    if (SwingUtilities.isEventDispatchThread()) {
        updateRowInternal(index, row);
    } else {
        try {
            SwingUtilities.invokeAndWait(new Runnable() {
                public void run() {
                    updateRowInternal(index, row);
                }
            });
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }

}

From source file:com.diversityarrays.kdxplore.curate.SampleEntryPanel.java

/**
 * @param show/*from  w  w  w . ja  v a  2  s . co  m*/
 */
private void updateStatsControls(boolean showStats) {

    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                updateStatsControls(showStats);
            }
        });
        return;
    }

    if (showStats) {
        repopulatingStatsControls = true;
        try {
            doRepopulateStatsControls();
        } finally {
            repopulatingStatsControls = false;
        }
        statisticsControls.setVisible(true);
    } else {
        statisticsControls.setVisible(false);

        for (JButton btn : statButtonByStatType.values()) {
            btn.setEnabled(false);
        }
        for (Component component : statComponentByStatType.values()) {
            component.setEnabled(false);
        }
    }
    this.repaint();
    this.updateUI();
}

From source file:edu.ku.brc.specify.dbsupport.BuildFromGeonames.java

private void doProgress(final int progress) {
    if (frame != null) {
        if (SwingUtilities.isEventDispatchThread()) {
            frame.setProcess(progress);//from w ww  .j  ava 2  s.com

        } else {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    frame.setProcess(progress);
                }
            });
        }
    }
}

From source file:com.archivas.clienttools.arcmover.gui.panels.ProfilePanel.java

public void refreshPathAndFileList() {
    if (!SwingUtilities.isEventDispatchThread()) {
        String errMsg = "refreshPathAndFileList is not on the EDT but it should be";
        IllegalStateException ex = new IllegalStateException(errMsg);
        LOG.log(Level.SEVERE, errMsg, ex);
        throw ex;
    }//from  w  w w  .ja v  a 2  s.c o m
    try {
        forceRefresh = true;
        if (currentDir.isVersionList()) {
            setPathAndFileListToDirectory(versionPath(currentDir));
        } else {
            setPathAndFileListToDirectory(currentDir.getPath());
        }
    } catch (Exception e1) {
        JOptionPane.showMessageDialog(this,
                "An error occurred refreshing the directory listing.  See logs for more information.",
                "Error Reloading Directory", JOptionPane.ERROR_MESSAGE);
        LOG.log(Level.WARNING, "An error occurred refreshing a directory listing: " + e1.toString(), e1);
    }
}

From source file:edu.ku.brc.specify.dbsupport.BuildFromGeonames.java

private void doProgress(final String msg) {
    if (frame != null) {
        if (SwingUtilities.isEventDispatchThread()) {
            frame.setDesc(msg);// w  ww  . j a v a 2s .c  o  m

        } else {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    frame.setDesc(msg);
                }
            });
        }
    }
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java

/**
 * Adds the given chatTransport to the given send via selector box.
 *
 * @param chatTransport the transport to add
 *//*from  w  ww. j a  v  a2s . c  o m*/
public void addChatTransport(final ChatTransport chatTransport) {
    // We need to be sure that the following code is executed in the event
    // dispatch thread.
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                addChatTransport(chatTransport);
            }
        });
        return;
    }

    if (transportSelectorBox != null) {
        transportSelectorBox.addChatTransport(chatTransport);

        // it was hidden cause we wanted to hide when there is only one
        // provider
        if (!transportSelectorBox.isVisible() && ConfigurationUtils.isHideAccountSelectionWhenPossibleEnabled()
                && transportSelectorBox.getMenu().getItemCount() > 1) {
            transportSelectorBox.setVisible(true);
        }
    }
}

From source file:hermes.browser.HermesBrowser.java

public void showInformationDialog(final String message) {
    Runnable r = new Runnable() {
        public void run() {
            JOptionPane.showMessageDialog(HermesBrowser.this, message, "Information",
                    JOptionPane.INFORMATION_MESSAGE);
        }/*from   w w  w  .j  a v a 2 s . c o m*/
    };

    if (SwingUtilities.isEventDispatchThread()) {
        r.run();
    } else {
        SwingUtilities.invokeLater(r);
    }
}