List of usage examples for javax.swing SwingUtilities invokeLater
public static void invokeLater(Runnable doRun)
From source file:Main.java
private void showBlocker() { SwingUtilities.invokeLater(new Runnable() { public void run() { blocker.setLocationRelativeTo(Main.this); blocker.setVisible(true);//from w w w . jav a 2s . c o m } }); }
From source file:com.gs.obevo.util.inputreader.DialogInputReader.java
@Override public String readLine(String promptMessage) { final JTextField juf = new JTextField(); JOptionPane juop = new JOptionPane(juf, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog userDialog = juop.createDialog(promptMessage); userDialog.addComponentListener(new ComponentAdapter() { @Override/*w ww . j a v a 2 s . co m*/ public void componentShown(ComponentEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { juf.requestFocusInWindow(); } }); } }); userDialog.setVisible(true); int uresult = (Integer) juop.getValue(); userDialog.dispose(); String userName = null; if (uresult == JOptionPane.OK_OPTION) { userName = new String(juf.getText()); } if (StringUtils.isEmpty(userName)) { return null; } else { return userName; } }
From source file:GUIUtils.java
public static void processOnSwingEventThread(Runnable todo, boolean wait) { if (todo == null) { throw new IllegalArgumentException("Runnable == null"); }/* w ww.j ava 2 s . c o m*/ if (wait) { if (SwingUtilities.isEventDispatchThread()) { todo.run(); } else { try { SwingUtilities.invokeAndWait(todo); } catch (Exception ex) { throw new RuntimeException(ex); } } } else { if (SwingUtilities.isEventDispatchThread()) { todo.run(); } else { SwingUtilities.invokeLater(todo); } } }
From source file:LiveParenMatcher.java
public void insertUpdate(DocumentEvent de) { SwingUtilities.invokeLater(this); // will call run() }
From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.diagnostics.LaunchDiagnosticTool.java
@Override public void run(CommandLine commandLine) throws Exception { SwingUtilities.invokeLater(new Runnable() { @Override/* w w w . java 2 s . c o m*/ public void run() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { //silently handle } DiagnosticTool diagnosticTool = new DiagnosticTool(); diagnosticTool.setIconImages(Settings.getIconImages()); diagnosticTool.setVisible(true); } }); }
From source file:com.codecrate.shard.ui.event.commandbus.BackgroundThreadActionCommandExecutor.java
public void execute(final Map params) { LOG.debug("Executing action in background thread: " + delegate); SwingUtilities.invokeLater(new Runnable() { public void run() { delegate.execute(params);/*from ww w.j a v a2 s . c o m*/ } }); }
From source file:io.github.mzmine.util.jfreechart.JFreeChartUtils.java
public static void printChart(ChartViewer chartNode) { // As of java 1.8.0_74, the JavaFX printing support seems to do poor // job. It creates pixelated, low-resolution print outs. For that // reason, we use the AWT PrinterJob class, until the JavaFX printing // support is improved. SwingUtilities.invokeLater(() -> { PrinterJob job = PrinterJob.getPrinterJob(); PageFormat pf = job.defaultPage(); PageFormat pf2 = job.pageDialog(pf); if (pf2 == pf) return; ChartPanel p = new ChartPanel(chartNode.getChart()); job.setPrintable(p, pf2);/*from w w w .jav a2 s. c om*/ if (!job.printDialog()) return; try { job.print(); } catch (PrinterException e) { e.printStackTrace(); MZmineGUI.displayMessage("Error printing: " + e.getMessage()); } }); }
From source file:com.aw.swing.mvp.focus.ConcurrentFocusManager.java
public void invokeLater(final String description, final Runnable runnable) { logger.debug("FocusConcur enqueued:" + description); SwingUtilities.invokeLater(new Runnable() { public void run() { logger.debug("FocusConcur dequeued:" + description); runnable.run();/*w w w .j a va 2s . c o m*/ } }); }
From source file:LiveParenMatcher.java
public void removeUpdate(DocumentEvent de) { SwingUtilities.invokeLater(this); // will call run() }
From source file:gui.accessories.GraphPopup.java
public void start() { //leave it here because we don't know from what thread it's coming from? SwingUtilities.invokeLater(new Runnable() { @Override//from w ww .j av a 2s.c o m public void run() { initAndShowFXGUI(); } }); }