本文整理汇总了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();
}
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
示例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);
}
示例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());
}
}
});
}
示例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];
}
}
示例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);
}
示例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();
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例14: isEventQueue
import java.awt.EventQueue; //导入方法依赖的package包/类
static boolean isEventQueue() {
return EventQueue.isDispatchThread();
}
示例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
//
}
}