Example usage for java.awt EventQueue invokeLater

List of usage examples for java.awt EventQueue invokeLater

Introduction

In this page you can find the example usage for java.awt EventQueue invokeLater.

Prototype

public static void invokeLater(Runnable runnable) 

Source Link

Document

Causes runnable to have its run method called in the #isDispatchThread dispatch thread of Toolkit#getSystemEventQueue the system EventQueue .

Usage

From source file:xtrememp.XtremeMP.java

@Override
public void playbackPaused(PlaybackEvent pe) {
    EventQueue.invokeLater(() -> {
        playPauseButton.setPlayIcon();//from   w ww . j a v  a  2s.  c o m
        playPauseMenuItem.setText(tr("MainFrame.Menu.Player.Play"));
    });
}

From source file:xtrememp.XtremeMP.java

@Override
public void playbackStopped(PlaybackEvent pe) {
    currentPli = null;//from  w w w  .j a v  a  2s .  c o m
    EventQueue.invokeLater(() -> {
        playPauseButton.setPlayIcon();
        stopButton.setEnabled(false);
        playPauseMenuItem.setText(tr("MainFrame.Menu.Player.Play"));
        stopMenuItem.setEnabled(false);
        acUpdateTime(0);
        statusLabel.setText("");
    });
}

From source file:me.paddingdun.gen.code.gui.view.dbtable.TableView.java

/**
 * table;//from   w w w  .  j av  a 2 s.c  o  m
 * 
 * @param list
 */
private void updateTableData(final List<TableColumn> list) {
    TaskHelper.runInNonEDT(new Callable<Void>() {
        @Override
        public Void call() throws Exception {

            Vector<Vector<Object>> v = TableHelper2.transform1(list);
            Vector<Object> v2 = new Vector<Object>();

            // final DefaultTableColumnModel dtcm = new
            // DefaultTableColumnModel();

            // ["??", ""]
            String[][] heads = new String[][] { { "", null }, // 0
                    { "", null }, // 1
                    { "??", null }, // 2
                    { "??", CellEditorType.String.name() }, // 3
                    { "?", CellEditorType.Number.name() }, // 4
                    { "??", null } // 5
            };

            for (int i = 0; i < heads.length; i++) {
                String[] tmp = heads[i];
                // javax.swing.table.TableColumn h = new
                // javax.swing.table.TableColumn(i);
                // h.setHeaderValue(tmp[0]);
                // dtcm.addColumn(h);
                v2.add(tmp[0]);
            }

            final DefaultTableModel dtm = new DefaultTableModel(v, v2) {
                private static final long serialVersionUID = 1L;

                /**
                 * ?;???;
                 */
                public Class<?> getColumnClass(int col) {
                    // //??
                    if (col == 4)
                        return Integer.class;
                    Object value = getValueAt(0, col);
                    if (value != null)
                        return value.getClass();
                    else
                        return super.getClass();
                }

                public boolean isCellEditable(int row, int column) {
                    if (column == 3 || column == 4
                    /* || column == 5 */)
                        return true;
                    return false;
                }
            };

            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    tableColumnTable.setModel(dtm);
                }
            });

            return null;
        }
    });
}

From source file:org.fhcrc.cpl.viewer.quant.gui.QuantitationReviewer.java

/**
 * Set status message.  Separate thread necessary or UI hangs
 * @param message/*from ww  w . jav  a  2s  . c  o m*/
 */
public void setMessage(String message) {
    if (EventQueue.isDispatchThread()) {
        if (null == message || 0 == message.length())
            message = " ";
        messageLabel.setText(message);
    } else {
        final String msg = message;
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                setMessage(msg);
            }
        });
    }
}

From source file:xtrememp.XtremeMP.java

@Override
public void acUpdateTime(int value) {
    StringBuilder timeText = new StringBuilder();
    if (currentPli != null) {
        String formattedLength = currentPli.getFormattedLength();
        long duration = TimeUnit.MILLISECONDS.toSeconds(value);
        if (Utilities.isNullOrEmpty(formattedLength)) {
            timeText.append(currentPli.getFormattedLength(duration));
        } else {//from  w w  w .  j  a  v a  2  s  .com
            timeText.append(currentPli.getFormattedLength(duration));
            timeText.append(" / ");
            timeText.append(formattedLength);
        }
    } else {
        timeText.append(Utilities.ZERO_TIMER);
    }

    final String timeStr = timeText.toString();
    final int seekValue = (currentPli == null) ? 0 : value;
    if (EventQueue.isDispatchThread()) {
        seekSlider.setValue(seekValue);
        timeLabel.setText(timeStr);
    } else {
        EventQueue.invokeLater(() -> {
            seekSlider.setValue(seekValue);
            timeLabel.setText(timeStr);
        });
    }
}

From source file:me.paddingdun.gen.code.gui.view.dbtable.TableView.java

/**
 * table;//from   ww w  .j a  v  a 2  s  .c  o m
 * modify by 2016618
 * ?"??", ???, ?, json;
 * @param list
 */
private void updateListData(final List<ListColumn> list) {
    TaskHelper.runInNonEDT(new Callable<Void>() {
        public Void call() throws Exception {
            String[] heads = { "", // 0
                    "??", // 1
                    "??", // 2
                    //                  "??", // 
                    "?", // 3
                    "?", // 4
                    "??", };
            Vector<String> v = new Vector<String>();
            for (String h : heads) {
                v.add(h);
            }
            Vector<Vector<Object>> vc = new Vector<Vector<Object>>();
            for (ListColumn lc : list) {
                Vector<Object> t = new Vector<Object>();
                t.add(Boolean.valueOf(lc.isPrimary()));
                t.add(lc.getColumnName());
                t.add(lc.getColumnAlias());
                //               String ta = lc.getTableAlias();
                //               if(StringUtils.isNotBlank(ta)){
                //                  t.add(ta);
                //               }else{
                //                  t.add("t1");
                //               }
                if (lc.getSeq() == null) {
                    if (lc.isPrimary())
                        t.add(IConsant.DEF_MIN_SEQ);
                    else
                        t.add(IConsant.DEF_MAX_SEQ);
                } else {
                    t.add(lc.getSeq());
                }
                t.add(lc.getOrder());
                t.add(lc.getColumnCommon());
                vc.add(t);
            }
            final DefaultTableModel dtm = new DefaultTableModel(vc, v) {
                /*
                 * (non-Javadoc)
                 * 
                 * @see
                 * javax.swing.table.AbstractTableModel#getColumnClass(int)
                 */
                @Override
                public Class<?> getColumnClass(int columnIndex) {
                    if (columnIndex == 3 || columnIndex == 4)
                        return Integer.class;
                    Object value = getValueAt(0, columnIndex);
                    if (value != null)
                        return value.getClass();
                    else
                        return super.getClass();
                }

                public boolean isCellEditable(int row, int column) {
                    if (column == 0 || column == 3 || column == 4)
                        return true;
                    return false;
                }
            };

            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    listColumnTable.setModel(dtm);
                }
            });
            return null;
        }
    });
}

From source file:org.zaproxy.zap.extension.zest.ExtensionZest.java

@Override
public boolean onHttpResponseReceive(final HttpMessage msg) {
    String secProxyHeader = msg.getRequestHeader().getHeader(HTTP_HEADER_X_SECURITY_PROXY);
    if (secProxyHeader != null) {
        String[] vals = secProxyHeader.split(",");
        for (String val : vals) {
            if (VALUE_RECORD.equalsIgnoreCase(val.trim())) {
                // TODO check script prefix??

                EventQueue.invokeLater(new Runnable() {
                    @Override/*ww w .j a  v a 2s  .  c  o  m*/
                    public void run() {
                        try {
                            addToParent(getRecordingNode(), msg, null);
                        } catch (Exception e) {
                            logger.error(e.getMessage(), e);
                        }
                    }
                });

                break;
            }
        }
    }
    for (final ScriptNode node : getZestScriptNodesWithCapability(ScriptType.CAPABILITY_APPEND)) {
        ZestScriptWrapper zsw = (ZestScriptWrapper) node.getUserObject();
        if (zsw.isRecording()) {
            if (msg.getRequestHeader().getURI().toString().startsWith(zsw.getZestScript().getPrefix())) {
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            addToParent(node, msg, null);
                        } catch (Exception e) {
                            logger.error(e.getMessage(), e);
                        }
                    }
                });
            }
        }
    }

    return true;
}

From source file:org.parosproxy.paros.extension.ExtensionLoader.java

private void removeViewInEDT(final Extension extension, final ExtensionHook hook) {
    if (view == null) {
        return;/*from   w w  w.j a v  a 2 s.c  o  m*/
    }

    if (EventQueue.isDispatchThread()) {
        removeView(extension, view, hook);
        removeMenu(view, hook);
    } else {
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                removeViewInEDT(extension, hook);
            }
        });
    }
}

From source file:com.t3.client.ui.T3Frame.java

public void close() {
    ServerDisconnectHandler.disconnectExpected = true;
    TabletopTool.disconnect();// w w  w . j a  v a  2 s.co  m

    getDockingManager().saveLayoutDataToFile(AppUtil.getAppHome("config").getAbsolutePath() + "/layout.dat");

    // If closing cleanly, remove the autosave file
    TabletopTool.getAutoSaveManager().purge();
    setVisible(false);

    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            dispose();
        }
    });
}

From source file:org.zaproxy.zap.extension.zest.ExtensionZest.java

private void addWindowLaunch(ScriptNode node, String handle, String url) {
    ZestScriptWrapper sw = this.getZestTreeModel().getScriptWrapper(node);
    if (!sw.getZestScript().getClientWindowHandles().contains(handle)) {
        final ZestClientLaunch launch = new ZestClientLaunch(handle, "firefox", url);

        EventQueue.invokeLater(new Runnable() {
            @Override//w  w w .j  a  va2  s  .  c  o m
            public void run() {
                try {
                    addToParent(getRecordingNode(), launch);
                } catch (Exception e) {
                    logger.error(e.getMessage(), e);
                }
            }
        });
    }
}