Java 类java.awt.EventQueue 实例源码

项目:OpenJSharp    文件:DataTransferer.java   
public void processDataConversionRequests() {
    if (EventQueue.isDispatchThread()) {
        AppContext appContext = AppContext.getAppContext();
        getToolkitThreadBlockedHandler().lock();
        try {
            Runnable dataConverter =
                (Runnable)appContext.get(DATA_CONVERTER_KEY);
            if (dataConverter != null) {
                dataConverter.run();
                appContext.remove(DATA_CONVERTER_KEY);
            }
        } finally {
            getToolkitThreadBlockedHandler().unlock();
        }
    }
}
项目:incubator-netbeans    文件:AWTTask.java   
@Override
public boolean waitFinished(long milliseconds) throws InterruptedException {
    if (EventQueue.isDispatchThread()) {
        PENDING.remove(this);
        run();
        return true;
    } else {
        WAKE_UP.wakeUp();
        synchronized (this) {
            if (isFinished()) {
                return true;
            }
            wait(milliseconds);
            return isFinished();
        }
    }
}
项目:jdk8u-jdk    文件:DataTransferer.java   
public void processDataConversionRequests() {
    if (EventQueue.isDispatchThread()) {
        AppContext appContext = AppContext.getAppContext();
        getToolkitThreadBlockedHandler().lock();
        try {
            Runnable dataConverter =
                (Runnable)appContext.get(DATA_CONVERTER_KEY);
            if (dataConverter != null) {
                dataConverter.run();
                appContext.remove(DATA_CONVERTER_KEY);
            }
        } finally {
            getToolkitThreadBlockedHandler().unlock();
        }
    }
}
项目:trashjam2017    文件:Hiero.java   
public void close () {
    final long endTime = System.currentTimeMillis();
    new Thread(new Runnable() {
        public void run () {
            if (endTime - startTime < minMillis) {
                addMouseListener(new MouseAdapter() {
                    public void mousePressed (MouseEvent evt) {
                        dispose();
                    }
                });
                try {
                    Thread.sleep(minMillis - (endTime - startTime));
                } catch (InterruptedException ignored) {
                }
            }
            EventQueue.invokeLater(new Runnable() {
                public void run () {
                    dispose();
                }
            });
        }
    }, "Splash").start();
}
项目:incubator-netbeans    文件:CodeTemplatesTest.java   
@RandomlyFails
public void testMemoryRelease() throws Exception { // Issue #147984
    org.netbeans.junit.Log.enableInstances(Logger.getLogger("TIMER"), "CodeTemplateInsertHandler", Level.FINEST);

    JEditorPane pane = new JEditorPane();
    NbEditorKit kit = new NbEditorKit();
    pane.setEditorKit(kit);
    Document doc = pane.getDocument();
    assertTrue(doc instanceof BaseDocument);
    CodeTemplateManager mgr = CodeTemplateManager.get(doc);
    String templateText = "Test with parm ";
    CodeTemplate ct = mgr.createTemporary(templateText + " ${a}");
    ct.insert(pane);
    assertEquals(templateText + " a", doc.getText(0, doc.getLength()));

    // Send Enter to stop editing
    KeyEvent enterKeyEvent = new KeyEvent(pane, KeyEvent.KEY_PRESSED,
            EventQueue.getMostRecentEventTime(),
            0, KeyEvent.VK_ENTER, KeyEvent.CHAR_UNDEFINED);

    SwingUtilities.processKeyBindings(enterKeyEvent);
    // CT editing should be finished

    org.netbeans.junit.Log.assertInstances("CodeTemplateInsertHandler instances not GCed");
}
项目:incubator-netbeans    文件:VCSAnnotationProviderTestCase.java   
private void startAnnotation(final Set<FileObject> files) {
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            lastEvent = System.currentTimeMillis();
            long time = System.currentTimeMillis();
            for (FileObject fo : files) {
                String name = fo.getNameExt();
                name = VersioningAnnotationProvider.getDefault().annotateNameHtml(name, Collections.singleton(fo));
                annotationsLabels.put(fo, name);
                Image image = ImageUtilities.assignToolTipToImage(VCSAnnotationProviderTestCase.IMAGE, fo.getNameExt());
                ImageUtilities.getImageToolTip(image);
                image = VersioningAnnotationProvider.getDefault().annotateIcon(image, 0, Collections.singleton(fo));
                annotationsIcons.put(fo, image);
            }
            time = System.currentTimeMillis() - time;
            if (time > 500) {
                ex = new Exception("Annotation takes more than 200ms");
            }
        }     
    });
}
项目:incubator-netbeans    文件:CommitPanel.java   
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
    if (evt.getKey().startsWith(HgModuleConfig.PROP_COMMIT_EXCLUSIONS)) {
        Runnable inAWT = new Runnable() {
            @Override
            public void run() {
                commitTable.dataChanged();
                listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
            }
        };
        // this can be called from a background thread - e.g. change of exclusion status in Versioning view
        if (EventQueue.isDispatchThread()) {
            inAWT.run();
        } else {
            EventQueue.invokeLater(inAWT);
        }
    }
}
项目:incubator-netbeans    文件:ShelveChangesAction.java   
@NbBundle.Messages({
    "MSG_ShelveAction.noModifications.text=There are no local modifications to shelve.",
    "LBL_ShelveAction.noModifications.title=No Local Modifications"
})
public void shelve (File repository, File[] roots) {
    if (Git.getInstance().getFileStatusCache().listFiles(roots,
            FileInformation.STATUS_MODIFIED_HEAD_VS_WORKING).length == 0) {
        // no local changes found
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run () {
                JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
                        Bundle.MSG_ShelveAction_noModifications_text(),
                        Bundle.LBL_ShelveAction_noModifications_title(),
                        JOptionPane.INFORMATION_MESSAGE);
            }
        });
        return;
    }
    GitShelveChangesSupport supp = new GitShelveChangesSupport(repository);
    if (supp.open()) {
        RequestProcessor rp = Git.getInstance().getRequestProcessor(repository);
        supp.startAsync(rp, repository, roots);
    }
}
项目:incubator-netbeans    文件:Utils.java   
/**
 * Switches the wait cursor on the NetBeans glasspane of/on
 * 
 * @param on
 */
public static void setWaitCursor(final boolean on) {
    Runnable r = new Runnable() {
        @Override
        public void run() {
            JFrame mainWindow = (JFrame) WindowManager.getDefault().getMainWindow();
            mainWindow
                .getGlassPane()
                .setCursor(Cursor.getPredefinedCursor(
                    on ?
                    Cursor.WAIT_CURSOR :
                    Cursor.DEFAULT_CURSOR));
            mainWindow.getGlassPane().setVisible(on);
        }
    };
    if(EventQueue.isDispatchThread()) {
        r.run();
    } else {
        EventQueue.invokeLater(r);
    }
}
项目:bbm487s2017g1    文件:LoginWindow.java   
/**
 * Launch the application.
 */
public static void main(String[] args) {

    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
      java.util.logging.Logger.getLogger(LoginWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
      JOptionPane.showMessageDialog(null, ex.getMessage());
    }

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                LoginWindow window = new LoginWindow();
                window.frmLibraryBookLoan.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}
项目:incubator-netbeans    文件:JFXProjectIconAnnotator.java   
/**
 * Gets the badge
 * @return badge or null if badge icon does not exist
 */
@NullUnknown
private Image getJFXBadge() {
    Image img = badgeCache.get();
    if (img == null) {
        if(!EventQueue.isDispatchThread()) {
            img = ImageUtilities.loadImage(JFX_BADGE_PATH);
            badgeCache.set(img);
        } else {
            final Runnable runLoadIcon = new Runnable() {
                @Override
                public void run() {            
                    badgeCache.set(ImageUtilities.loadImage(JFX_BADGE_PATH));
                    cs.fireChange();
                }
            };
            final RequestProcessor RP = new RequestProcessor(JFXProjectIconAnnotator.class.getName());
            RP.post(runLoadIcon);
        }
    }
    return img;
}
项目:openjdk-jdk10    文件:ProgressBarMemoryLeakTest.java   
private static void executeTestCase(String lookAndFeelString) throws Exception{
  if (tryLookAndFeel(lookAndFeelString)) {
    EventQueue.invokeAndWait( new Runnable() {
      @Override
      public void run() {
        showUI();
      }
    } );
    EventQueue.invokeAndWait( new Runnable() {
      @Override
      public void run() {
        disposeUI();
      }
    } );
    Util.generateOOME();
    JProgressBar progressBar = sProgressBar.get();
    if ( progressBar != null ) {
      throw new RuntimeException( "Progress bar (using L&F: " + lookAndFeelString + ") should have been GC-ed" );
    }
  }
}
项目:Project-SADS    文件:MainWindow.java   
/**
 * Launch the application.
 */
public static void main(String[] args)
{
    if(args.length > 0)
        DEBUG = args[0].equalsIgnoreCase("debug");

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                MainWindow window = new MainWindow();
                window.frmStringSequenceAnalyzer.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}
项目:incubator-netbeans    文件:DiffViewManager.java   
@Override
public void run() {
    diffSerial = cachedDiffSerial;
    computeSecondHighlights();
    if (diffSerial != cachedDiffSerial) {
        return;
    }
    computeFirstHighlights();
    if (diffSerial == cachedDiffSerial) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                master.getEditorPane1().fireHilitingChanged();
                master.getEditorPane2().fireHilitingChanged();
            }
        });
    }
}
项目:incubator-netbeans    文件:ListViewWithUpTest.java   
private static <T> T awtRequest(final Callable<T> call) throws Exception {
    final AtomicReference<T> value = new AtomicReference<T>();
    final Exception[] exc = new Exception[1];
    EventQueue.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            try {
                value.set(call.call());
            } catch (Exception ex) {
                exc[0] = ex;
            }
        }
    });

    if (exc[0] != null) throw exc[0];
    return value.get();
}
项目:incubator-netbeans    文件:EventLock.java   
/**
 * Similar to {@link EventQueue#invokeAndWait} but posts the event at the same
 * priority as paint requests, to avoid bad visual artifacts.
 */
static void invokeAndWaitLowPriority(RWLock m, Runnable r)
        throws InterruptedException, InvocationTargetException {
    Toolkit t = Toolkit.getDefaultToolkit();
    EventQueue q = t.getSystemEventQueue();
    Object lock = new PaintPriorityEventLock();
    InvocationEvent ev = new PaintPriorityEvent(m, t, r, lock, true);
    synchronized (lock) {
        q.postEvent(ev);
        lock.wait();
    }
    Exception e = ev.getException();
    if (e != null) {
        throw new InvocationTargetException(e);
    }
}
项目:OpenJSharp    文件:MBeansTab.java   
public void handleNotification(
        final Notification notification, Object handback) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            if (notification instanceof MBeanServerNotification) {
                ObjectName mbean =
                        ((MBeanServerNotification) notification).getMBeanName();
                if (notification.getType().equals(
                        MBeanServerNotification.REGISTRATION_NOTIFICATION)) {
                    tree.addMBeanToView(mbean);
                } else if (notification.getType().equals(
                        MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
                    tree.removeMBeanFromView(mbean);
                }
            }
        }
    });
}
项目:incubator-netbeans    文件:RepositoryRevision.java   
@Override
protected void perform () {
    Map<File, GitFileInfo> files;
    try {
        files = getLog().getModifiedFiles();
    } catch (GitException ex) {
        GitClientExceptionHandler.notifyException(ex, true);
        files = Collections.<File, GitFileInfo>emptyMap();
    }
    final List<Event> logEvents = prepareEvents(files);
    if (!isCanceled()) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run () {
                if (!isCanceled()) {
                    events.clear();
                    dummyEvents.clear();
                    events.addAll(logEvents);
                    eventsInitialized = true;
                    currentSearch = null;
                    support.firePropertyChange(RepositoryRevision.PROP_EVENTS_CHANGED, null, new ArrayList<Event>(events));
                }
            }
        });
    }
}
项目:incubator-netbeans    文件:UpdateResults.java   
public UpdateResults(List<FileUpdateInfo> results, SVNUrl url, String contextDisplayName) {
    this.results = results;
    String time = DateFormat.getTimeInstance().format(new Date());
    setName(NbBundle.getMessage(UpdateResults.class, "CTL_UpdateResults_Title", SvnUtils.decodeToString(url), contextDisplayName, time)); // NOI18N
    setLayout(new BorderLayout());
    if (results.size() == 0) {
        add(new NoContentPanel(NbBundle.getMessage(UpdateResults.class, "MSG_NoFilesUpdated"))); // NOI18N
    } else {
        final UpdateResultsTable urt = new UpdateResultsTable();
        Subversion.getInstance().getRequestProcessor().post(new Runnable () {
            public void run() {
                final UpdateResultNode[] nodes = createNodes();
                EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        urt.setTableModel(nodes);
                        add(urt.getComponent());
                    }
                });
            }
        });
    }
}
项目:SnakeAndLadder    文件:Main.java   
/**
 * Launch the application.
 */



public static void main(String[] args) {                    //ekhane dhukar drkr nai :/
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Main frame = new Main();
                frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}
项目:OpenJSharp    文件:SwingUtilities3.java   
@SuppressWarnings("unchecked")
public EventQueueDelegateFromMap(Map<String, Map<String, Object>> objectMap) {
    Map<String, Object> methodMap = objectMap.get("afterDispatch");
    afterDispatchEventArgument = (AWTEvent[]) methodMap.get("event");
    afterDispatchHandleArgument = (Object[]) methodMap.get("handle");
    afterDispatchCallable = (Callable<Void>) methodMap.get("method");

    methodMap = objectMap.get("beforeDispatch");
    beforeDispatchEventArgument = (AWTEvent[]) methodMap.get("event");
    beforeDispatchCallable = (Callable<Object>) methodMap.get("method");

    methodMap = objectMap.get("getNextEvent");
    getNextEventEventQueueArgument =
        (EventQueue[]) methodMap.get("eventQueue");
    getNextEventCallable = (Callable<AWTEvent>) methodMap.get("method");
}
项目:Recaf    文件:SwingUI.java   
public void init(LaunchParams params) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setSize(params.getSize());
                frame.setJMenuBar(menuBar);
                frame.getContentPane().setLayout(new BorderLayout(0, 0));
                setupMenu();
                setupPane();
            } catch (Exception exception) {
                Recaf.INSTANCE.logging.error(exception);
            }
        }
    });
}
项目:incubator-netbeans    文件:FavoritesTest.java   
@RandomlyFails // got empty list of nodes in NB-Core-Build #3603
public void testSelectWithAdditionExisting() throws Exception {
    RootsTest.clearBareFavoritesTabInstance();
    TopComponent win = RootsTest.getBareFavoritesTabInstance();
    assertNull(win);
    fav.add(file);
    assertTrue(fav.isInFavorites(file));
    fav.selectWithAddition(file);
    win = RootsTest.getBareFavoritesTabInstance();
    assertNotNull(win);
    assertTrue(win.isOpened());
    assertTrue(fav.isInFavorites(file));
    EventQueue.invokeAndWait(new Runnable() {   // Favorites tab EM refreshed in invokeLater, we have to wait too

        public void run() {
            ExplorerManager man = ((ExplorerManager.Provider) RootsTest.getBareFavoritesTabInstance()).getExplorerManager();
            assertNotNull(man);
            Node[] nodes = man.getSelectedNodes();
            assertEquals(Arrays.toString(nodes), 1, nodes.length);
            assertEquals(TEST_TXT, nodes[0].getName());
        }

    });
}
项目:incubator-netbeans    文件:SearchHistoryAction.java   
public static void openSearch (final File repository, final File root, final String contextName, final int lineNumber) {
    final String title = NbBundle.getMessage(SearchHistoryTopComponent.class, "LBL_SearchHistoryTopComponent.title", contextName);
    final RepositoryInfo info = RepositoryInfo.getInstance(repository);
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run () {
            SearchHistoryTopComponent tc = new SearchHistoryTopComponent(repository, info, root, new SearchHistoryTopComponent.DiffResultsViewFactory() {
                @Override
                DiffResultsView createDiffResultsView(SearchHistoryPanel panel, List<RepositoryRevision> results) {
                    return new DiffResultsViewForLine(panel, results, lineNumber);
                }
            });
            tc.setDisplayName(title);
            tc.open();
            tc.requestActive();
            tc.search(true);
            tc.activateDiffView(true);
        }
    });
}
项目:incubator-netbeans    文件:VCSCommitPanel.java   
@Override
public void preferenceChange(PreferenceChangeEvent evt) {        
    if (evt.getKey().startsWith(PROP_COMMIT_EXCLUSIONS)) { // XXX - need setting
        Runnable inAWT = new Runnable() {
            @Override
            public void run() {
                commitTable.dataChanged();
                listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
            }
        };
        // this can be called from a background thread - e.g. change of exclusion status in Versioning view
        if (EventQueue.isDispatchThread()) {
            inAWT.run();
        } else {
            EventQueue.invokeLater(inAWT);
        }
    }
}
项目:incubator-netbeans    文件:SelectInstallationPanel.java   
@NbBundle.Messages({
    "MSG_Detecting_Wait=Detecting installations, please wait..."
})
private void initList() {
    installationList.setListData(new Object[]{
        Bundle.MSG_Detecting_Wait()
    });
    installationList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    installationList.setEnabled(false);

    RequestProcessor.getDefault().post(new Runnable() {
        @Override
        public void run() {
            final List<Installation> installations =
                    InstallationManager.detectAllInstallations();
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    updateListForDetectedInstallations(installations);
                }
            });
        }
    });
}
项目:incubator-netbeans    文件:ReporterResultTopComponent.java   
@Override
public void run() {
    if (EventQueue.isDispatchThread()){
        try {
            loadPage(new URL(urlStr), show);
        } catch (MalformedURLException ex) {
            handleIOException(urlStr, ex);
        }
    }else{
        String userName = new ExceptionsSettings().getUserName();
        if (userName != null && !"".equals(userName)) {             //NOI18N
            urlStr = NbBundle.getMessage(ReporterResultTopComponent.class, "userNameURL") + userName;
        } else {
            String userId = Installer.findIdentity();
            if (userId != null) {
                urlStr = NbBundle.getMessage(ReporterResultTopComponent.class, "userIdURL") + userId;
            }
        }
        if (urlStr == null) {
            return; // XXX prompt to log in?
        }
        EventQueue.invokeLater(this);
    }
}
项目:incubator-netbeans    文件:TimableEventQueueTest.java   
public void testDispatchEvent() throws Exception {
    class Slow implements Runnable {
        private int ok;
        @Override
        public void run() {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                Exceptions.printStackTrace(ex);
            }
            ok++;
        }
    }
    Slow slow = new Slow();

    EventQueue.invokeAndWait(slow);
    EventQueue.invokeAndWait(slow);
    TimableEventQueue.RP.shutdown();
    TimableEventQueue.RP.awaitTermination(3, TimeUnit.SECONDS);

    assertEquals("called", 2, slow.ok);

    if (!log.toString().contains("too much time in AWT thread")) {
        fail("There shall be warning about too much time in AWT thread:\n" + log);
    }
}
项目:incubator-netbeans    文件:AsynchChildren.java   
/**
 * Notify this AsynchChildren that it should reconstruct its children,
 * calling <code>provider.asynchCreateKeys()</code> and setting the
 * keys to that.  Call this method if the list of child objects is known
 * or likely to have changed.
 * @param immediate If true, the keys are updated synchronously from the
 *  calling thread.  Set this to true only if you know that updating
 *  the keys will <i>not</i> be an expensive or time-consuming operation.
 */ 
public void refresh(boolean immediate) {
    immediate &= !EventQueue.isDispatchThread();
    logger.log (Level.FINE, "Refresh on {0} immediate {1}", new Object[]  //NOI18N
        { this, immediate });
    if (logger.isLoggable(Level.FINEST)) {
        logger.log (Level.FINEST, "Refresh: ", new Exception()); //NOI18N
    }
    if (immediate) {
        boolean done;
        List <T> keys = new LinkedList <T> ();
        do {
            done = factory.createKeys(keys);
        } while (!done);
        setKeys (keys);
    } else {
        task.schedule (0);
    }
}
项目:Progetto-B    文件:GraphicsJLabel.java   
/**
 * Draws a black triangle-shaped shadow with the vertix in the middle of the
 * Rectangle <code> from</code> and the base centred in the middle of the
 * Rectangle <code>to</code>. The base width is determined by the parameter
 * <code>defaultWidth</code>. the base at <code>base</code>.
 *
 * @param vertix
 * @param base
 */
private void draw(Rectangle from, Rectangle to) {
    GraphicsJLabel label = this;
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            xx[0] = from.getX() + from.getWidth() / 2;
            yy[0] = from.getY() + from.getHeight() / 2;
            xx[1] = to.getX() + to.getWidth() / 2;
            yy[1] = to.getY() + to.getHeight() / 2;
            double alpha = atan(Math.abs((xx[1] - xx[0]) / (yy[1] - yy[0])));
            xx[2] = xx[1] + DEFAULT_WIDTH * cos(alpha);
            yy[2] = yy[1] + DEFAULT_WIDTH * sin(alpha);
            label.updateUI();
        }
    });

}
项目:tttclass    文件:JavavcCameraTest.java   
public static void main(String[] args) throws Exception, InterruptedException {
    EventQueue.invokeLater(new Runnable()
    {
        public void run()
        {
            try
            {
                JavavcCameraTest gabber = new JavavcCameraTest(0);
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
        }
    });

}
项目:incubator-netbeans    文件:CssStylesPanel.java   
private void updateToolbar(final FileObject file) {
    RP.post(new Runnable() {

        @Override
        public void run() {
            //getActiveProviders() must not be called in EDT as it might do some I/Os
            final Collection<CssStylesPanelProvider> activeProviders = getActiveProviders(file);
            EventQueue.invokeLater(new Runnable() {

                @Override
                public void run() {
                    updateToolbar(file, activeProviders);
                }

            });
        }

    });
}
项目:incubator-netbeans    文件:UnshelveChangesAction.java   
private void initializePatches () {
    panel.cmbPatches.setModel(new DefaultComboBoxModel(new String[] { LOADING_PATCHES }));
    validate();
    Utils.postParallel(new Runnable() {
        @Override
        public void run () {
            final List<Patch> patches = PatchStorage.getInstance().getPatches();
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run () {
                    panel.cmbPatches.setModel(new DefaultComboBoxModel(patches.toArray(new Patch[patches.size()])));
                    if (!patches.isEmpty()) {
                        panel.cmbPatches.setSelectedIndex(0);
                    }
                }
            });
        }
    }, 0);
}
项目:incubator-netbeans    文件:ExplorerActionsImpl.java   
public final void waitFinished() {
    ActionStateUpdater u = actionStateUpdater;
    synchronized (this) {
        u = actionStateUpdater;
    }
    if (u == null) {
        return;
    }
    u.waitFinished();
    if (EventQueue.isDispatchThread()) {
        u.run();
    } else {
        try {
            EventQueue.invokeAndWait(u);
        } catch (Exception ex) {
            Exceptions.printStackTrace(ex);
        }
    }
}
项目:incubator-netbeans    文件:OpenRepositoryAction.java   
@Override
public void actionPerformed (ActionEvent event) {
    final File f = new FileChooserBuilder(OpenRepositoryAction.class).setDirectoriesOnly(true)
            .setApproveText(Bundle.CTL_OpenRepository_okButton())
            .setAccessibleDescription(Bundle.CTL_OpenRepository_ACSD())
            .showOpenDialog();
    if (f == null) {
        return;
    }
    Utils.postParallel(new Runnable () {
        @Override
        public void run() {
            final File repository = Git.getInstance().getRepositoryRoot(f);
            if (repository != null) {
                GitRepositories.getInstance().add(repository, true);
                EventQueue.invokeLater(new Runnable() {

                    @Override
                    public void run () {
                        GitRepositoryTopComponent rtc = GitRepositoryTopComponent.findInstance();
                        rtc.open();
                        rtc.requestActive();
                        rtc.selectRepository(repository);
                    }
                });
            }
        }
    }, 0);
}
项目:incubator-netbeans    文件:ExplorerActionsImplTest.java   
@Override
protected void createPasteTypes(Transferable t, List<PasteType> s) {
    assertFalse("Don't block AWT", EventQueue.isDispatchThread());
    if (pasteTypes != null) {
        s.addAll(pasteTypes);
    }
}
项目:Sensors    文件:Interface.java   
/**
 * Launch the application.
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Interface window = new Interface();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}
项目:openjdk-jdk10    文件:ProgressMonitorEscapeKeyPress.java   
public static void main(String[] args) throws Exception {

        createTestUI();

        monitor = new ProgressMonitor(frame, "Progress", null, 0, 100);

        robotThread = new TestThread();
        robotThread.start();

        for (counter = 0; counter <= 100; counter += 10) {
            Thread.sleep(1000);

            EventQueue.invokeAndWait(new Runnable() {
                @Override
                public void run() {
                    if (!monitor.isCanceled()) {
                        monitor.setProgress(counter);
                        System.out.println("Progress bar is in progress");
                    }
                }
            });

            if (monitor.isCanceled()) {
                break;
            }
        }

        disposeTestUI();

        if (counter >= monitor.getMaximum()) {
            throw new RuntimeException("Escape key did not cancel the ProgressMonitor");
        }
    }
项目:jijimaku    文件:TextAreaOutputStream.java   
synchronized void append(String val) {
  values.add(val);
  if (queue) {
    queue = false;
    EventQueue.invokeLater(this);
  }
}
项目:incubator-netbeans    文件:ActiveConfigAction.java   
private void configurationsListChanged(@NullAllowed Collection<? extends ProjectConfiguration> configs) {
    LOGGER.log(Level.FINER, "configurationsListChanged: {0}", configs);
    ProjectConfigurationProvider<?> _pcp;
    synchronized (this) {
        _pcp = pcp;
    }
    if (configs == null) {
        EventQueue.invokeLater(new Runnable() {
            public @Override void run() {
                configListCombo.setModel(EMPTY_MODEL);
                configListCombo.setEnabled(false); // possibly redundant, but just in case
            }
        });
    } else {
        final DefaultComboBoxModel model = new DefaultComboBoxModel(configs.toArray());
        if (_pcp != null && _pcp.hasCustomizer()) {
            model.addElement(CUSTOMIZE_ENTRY);
        }
        EventQueue.invokeLater(new Runnable() {
            public @Override void run() {
                configListCombo.setModel(model);
                configListCombo.setEnabled(true);
            }
        });
    }
    if (_pcp != null) {
        activeConfigurationChanged(getActiveConfiguration(_pcp));
    }
}