List of usage examples for javax.swing SwingUtilities invokeLater
public static void invokeLater(Runnable doRun)
From source file:Main.java
public static <T> void invokeLater(Callable<T> callable, JSObject callback) { SwingUtilities.invokeLater(() -> { try {// w ww . ja va2 s . c om final T result = callable.call(); if (callback != null) { Platform.runLater(() -> callback.call("call", null, result)); } } catch (Exception e) { e.printStackTrace(); } }); }
From source file:Main.java
/** * Runs the specified runnable in the EDT using * <code>SwingUtilities.invokeLater(...)</code>. * * @param runnable - the runnable to be executed *//* w w w.j av a2s.co m*/ public static void invokeLater(Runnable runnable) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(runnable); } else { runnable.run(); } }
From source file:Main.java
/** * Setta il focus su form modali//from ww w.j a va2 s .com * * @param target componente che ricevera' il focus */ public static void postponeFocus(final Component target) { SwingUtilities.invokeLater(new Runnable() { public void run() { target.dispatchEvent(new FocusEvent(target, FocusEvent.FOCUS_GAINED)); } }); }
From source file:Main.java
/** * Focus a component./*w w w. ja va 2 s . co m*/ * * <p>The focus call happens in {@link SwingUtilities#invokeLater(Runnable)}.</p> * * @param component the component */ public static void focusLater(final Component component) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (component instanceof JTextComponent) { ((JTextComponent) component).selectAll(); } component.requestFocusInWindow(); } }); }
From source file:Main.java
/** * Invokes {@code run} immediately if this is the * EDT; otherwise, the {@code Runnable} is invoked * on the EDT using {@code invokeLater}. *//*from w ww . ja v a 2 s . c o m*/ public static void invokeNowOrLater(Runnable run) { if (SwingUtilities.isEventDispatchThread()) { run.run(); } else { SwingUtilities.invokeLater(run); } }
From source file:Main.java
private static void doSetVisible(final Component component, final boolean isVisible) { if (component != null) { if (SwingUtilities.isEventDispatchThread()) { doSetVisibleInEDT(component, isVisible); } else {// w ww.j a va 2 s . c o m SwingUtilities.invokeLater(new Runnable() { @Override public void run() { doSetVisibleInEDT(component, isVisible); } }); } } }
From source file:Main.java
/** * Invokes the target runnable on the event dispatch thread. This is equivalent to SwingUtilities.invokeLater(...), * this method was just put here to have all the invoke-methods in one place. * * @param r Runnable to start./* w w w. j a v a2 s. co m*/ */ public static void invokeOnEDT(final Runnable r) { SwingUtilities.invokeLater(r); }
From source file:Main.java
private static void doSetSelected(final AbstractButton abstractButton, final boolean isSelected) { if (abstractButton != null) { if (SwingUtilities.isEventDispatchThread()) { doSetSelectedInEDT(abstractButton, isSelected); } else {// w w w.j a va2 s . c om SwingUtilities.invokeLater(new Runnable() { @Override public void run() { doSetSelectedInEDT(abstractButton, isSelected); } }); } } }
From source file:LocationSensitiveDemo.java
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); increaseFont("Tree.font"); increaseFont("Label.font"); increaseFont("ComboBox.font"); increaseFont("List.font"); } catch (Exception e) { }/*from ww w . j a v a 2 s . co m*/ // Turn off metal's use of bold fonts UIManager.put("swing.boldMetal", Boolean.FALSE); createAndShowGUI(); } }); }
From source file:projects.hip.exec.HrDiagram.java
/** * Main application entry point.// w w w . j a v a 2 s . c om * @param args * The args - ignored. */ public static void main(String[] args) { final JFrame frame = new JFrame("Hipparcos HR diagram"); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new HrDiagram(), BorderLayout.CENTER); frame.setSize(1500, 750); frame.pack(); frame.setVisible(true); } }); }