當前位置: 首頁>>代碼示例>>Java>>正文


Java EventQueue.isDispatchThread方法代碼示例

本文整理匯總了Java中java.awt.EventQueue.isDispatchThread方法的典型用法代碼示例。如果您正苦於以下問題:Java EventQueue.isDispatchThread方法的具體用法?Java EventQueue.isDispatchThread怎麽用?Java EventQueue.isDispatchThread使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.EventQueue的用法示例。


在下文中一共展示了EventQueue.isDispatchThread方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processDataConversionRequests

import java.awt.EventQueue; //導入方法依賴的package包/類
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();
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:DataTransferer.java

示例2: refresh

import java.awt.EventQueue; //導入方法依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:AsynchChildren.java

示例3: run

import java.awt.EventQueue; //導入方法依賴的package包/類
@Override
public void run() {
    if (EventQueue.isDispatchThread()){
        panel.setText(panelContent.toString());
        panel.getExplorerManager().setRootContext(root);
    } else {
        List<LogRecord> displayedRecords = new ArrayList<>(recs);
        LinkedList<Node> nodes = new LinkedList<>();
        root.setName("root"); // NOI18N
        root.setDisplayName(NbBundle.getMessage(Installer.class, "MSG_RootDisplayName", displayedRecords.size() + 1, new Date()));
        root.setIconBaseWithExtension("org/netbeans/modules/uihandler/logs.gif");
        for (LogRecord r : displayedRecords) {
            procesLog(r, nodes, panelContent);
        }
        procesLog(getUserData(false, reportPanel), nodes, panelContent);
        root.getChildren().add(nodes.toArray(new Node[0]));
        EventQueue.invokeLater(this);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:Installer.java

示例4: run

import java.awt.EventQueue; //導入方法依賴的package包/類
@Override
public void run() {
    if (!EventQueue.isDispatchThread()) {
        try {
            try {
                waitForTaskAssignment.await();
            } catch (InterruptedException ex) {
                Exceptions.printStackTrace(ex);
            }
            operationResult = runBackground();
        } finally {
            EventQueue.invokeLater(this);
        }
    } else {
        dlg.setVisible(false);
        dlg.dispose();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:AbstractWindowRunner.java

示例5: recognizesTargetChooserStep

import java.awt.EventQueue; //導入方法依賴的package包/類
@Test
public void recognizesTargetChooserStep() {
    changeListener = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            edt = EventQueue.isDispatchThread();
            notified.countDown();
            assertTrue("Changes only in edt", edt);
        }
    };
    this.addChangeListener(changeListener);


    TemplateWizard tw = new TemplateWizard();
    List<WizardDescriptor.Panel<WizardDescriptor>> arr = new ArrayList<>();
    
    AbstractWizard.fillPanels(tw, this, arr, Arrays.asList("One", "targetChooser", "Three"));
    this.fireChange();
    
    assertEquals("Three panels: " + arr, 3, arr.size());
    assertTrue(arr.get(0) instanceof HTMLPanel);
    assertEquals(tw.targetChooser(), arr.get(1));
    assertTrue(arr.get(2) instanceof HTMLPanel);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:ChooserPanelTest.java

示例6: push

import java.awt.EventQueue; //導入方法依賴的package包/類
public void push (final File repository) {
    if (EventQueue.isDispatchThread()) {
        Utils.post(new Runnable () {
            @Override
            public void run () {
                push(repository);
            }
        });
        return;
    }
    RepositoryInfo info = RepositoryInfo.getInstance(repository);
    try {
        info.refreshRemotes();
    } catch (GitException ex) {
        GitClientExceptionHandler.notifyException(ex, true);
    }
    final Map<String, GitRemoteConfig> remotes = info.getRemotes();
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run () {
            PushWizard wiz = new PushWizard(repository, remotes);
            if (wiz.show()) {
                Utils.logVCSExternalRepository("GIT", wiz.getPushUri()); //NOI18N
                push(repository, wiz.getPushUri(), wiz.getPushMappings(), wiz.getFetchRefSpecs(), wiz.getRemoteName());
            }
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:PushAction.java

示例7: parseButtons

import java.awt.EventQueue; //導入方法依賴的package包/類
/** Tries to parse a list of buttons provided by given page.
 * @param is the input stream to read the page from
 * @param defaultButton the button to add always to the list
 */
static void parseButtons(InputStream is, final Object defaultButton, final DialogDescriptor dd)
        throws IOException, ParserConfigurationException, SAXException, InterruptedException, InvocationTargetException {
    final ButtonsHTMLParser bp = new ButtonsHTMLParser(is);
    final IOException[] ioExPtr = new IOException[] { null };
    Runnable buttonsCreation = new Runnable() {
        @Override
        public void run() {
            try {
                bp.parse();
            } catch (IOException ioex) {
                ioExPtr[0] = ioex;
                return ;
            }
            bp.createButtons();
            List<Object> options = bp.getOptions();
            if (!bp.containsExitButton() && (defaultButton != null)){
                options.add(defaultButton);
            }
            dd.setOptions(options.toArray());
            dd.setAdditionalOptions(bp.getAdditionalOptions().toArray());
            if (bp.getTitle() != null){
                dd.setTitle(bp.getTitle());
            }
        }
    };
    
    if (EventQueue.isDispatchThread()){
        buttonsCreation.run();
    }else{
        EventQueue.invokeAndWait(buttonsCreation);
    }
    if (ioExPtr[0] != null) {
        throw ioExPtr[0];
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:40,代碼來源:Installer.java

示例8: drawText

import java.awt.EventQueue; //導入方法依賴的package包/類
private int drawText(Graphics g,
                     int x, int y,
                     int startOffset, int endOffset,
                     boolean error,
                     boolean selected,
                     DocElement docElem) throws BadLocationException {
    Segment s = EventQueue.isDispatchThread() ? SEGMENT : new Segment(); 
    s.array = docElem.getChars();
    s.offset = startOffset - docElem.offset;
    s.count = endOffset - startOffset;

    g.setColor(getColor(error, selected));

    return Utilities.drawTabbedText(s, x, y, g, this, startOffset);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:OutputView.java

示例9: paint

import java.awt.EventQueue; //導入方法依賴的package包/類
@Override
public void paint(final Graphics g) {
    super.paint(g);
    if (!EventQueue.isDispatchThread()) {
        throw new RuntimeException("Wrong thread");
    }
    test();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:9,代碼來源:LabelRepaint.java

示例10: invokeSmoothly

import java.awt.EventQueue; //導入方法依賴的package包/類
/**
 * Being executed outside of AWT dispatching thread, invokes a runnable
 * through the event queue. Otherwise executes {@code runnable.run()}
 * method directly.
 *
 * @param runnable a runnable to be executed.
 */
public void invokeSmoothly(Runnable runnable) {
    if (!EventQueue.isDispatchThread()) {
        invokeAndWait(runnable);
    } else {
        runnable.run();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:QueueTool.java

示例11: showDiff

import java.awt.EventQueue; //導入方法依賴的package包/類
public void showDiff(final RepositoryRevision container) {
    Runnable r = new Runnable() {
        @Override
        public void run() {
            tbDiff.setSelected(true);
            refreshComponents(true);
            diffView.select(container);
        }
    };
    if(EventQueue.isDispatchThread()) {
        r.run();
    } else {
        EventQueue.invokeLater(r);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:SearchHistoryPanel.java

示例12: notifyParsingError

import java.awt.EventQueue; //導入方法依賴的package包/類
/**
 * Notifies user of parsing error.
 */
public static void notifyParsingError() {
    NotifyDescriptor nd = new NotifyDescriptor(
            NbBundle.getMessage(HgModuleConfig.class, "MSG_ParsingError"), // NOI18N
            NbBundle.getMessage(HgModuleConfig.class, "LBL_ParsingError"), // NOI18N
            NotifyDescriptor.DEFAULT_OPTION,
            NotifyDescriptor.ERROR_MESSAGE,
            new Object[]{NotifyDescriptor.OK_OPTION, NotifyDescriptor.CANCEL_OPTION},
            NotifyDescriptor.OK_OPTION);
    if (EventQueue.isDispatchThread()) {
        DialogDisplayer.getDefault().notify(nd);
    } else {
        DialogDisplayer.getDefault().notifyLater(nd);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:HgModuleConfig.java

示例13: showDiffError

import java.awt.EventQueue; //導入方法依賴的package包/類
protected void showDiffError (final String s) {
    Runnable inAWT = new Runnable() {
        @Override
        public void run() {
            setBottomComponent(new NoContentPanel(s));
        }
    };
    if (EventQueue.isDispatchThread()) {
        inAWT.run();
    } else {
        EventQueue.invokeLater(inAWT);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:DiffResultsView.java

示例14: isEventQueue

import java.awt.EventQueue; //導入方法依賴的package包/類
static boolean isEventQueue() {
    return EventQueue.isDispatchThread();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:4,代碼來源:CThreading.java

示例15: waitFinished

import java.awt.EventQueue; //導入方法依賴的package包/類
/** Overrides the instance finished to deal with
 * internal state correctly.
 */
public @Override void waitFinished() {
    boolean isLog = err.isLoggable(Level.FINE);
    for (;;) {
        err.fine("waitProcessingFinished on container"); // NOI18N
        waitProcessingFinished (container);

        Task originalRecognizing = checkRecognizingStarted ();
        if (isLog) {
            err.fine("checkRecognizingStarted: " + originalRecognizing); // NOI18N
        }
        originalRecognizing.waitFinished ();

        Task t = creationTask;
        if (isLog) {
            err.fine("creationTask: " + t); // NOI18N
        }
        if (t != null) {
            if (EventQueue.isDispatchThread()) {
                if (!AWTTask.waitFor(t)) {
                    continue;
                }
            } else {
                t.waitFinished();
            }
        }


        Task[] toWait = waitFor;
        if (isLog) {
            err.fine("toWait: " + Arrays.toString(toWait)); // NOI18N
        }
        if (toWait != null) {
            for (int i = 0; i < toWait.length; i++) {
                if (isLog) {
                    err.fine("  wait[" + i + "]: " + toWait[i]); // NOI18N
                }
                toWait[i].waitFinished ();
            }
        }

        // loop if there was yet another task started to compute the
        // children list
        if (originalRecognizing == checkRecognizingStarted ()) {
            if (isLog) {
                err.fine("breaking the wait loop"); // NOI18N
            }
            break;
        }
        
        //
        // otherwise go on an try it once more
        //
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:58,代碼來源:FolderInstance.java


注:本文中的java.awt.EventQueue.isDispatchThread方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。