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


Java EventQueue類代碼示例

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


EventQueue類屬於java.awt包,在下文中一共展示了EventQueue類的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:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:DataTransferer.java

示例2: waitFinished

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

示例3: close

import java.awt.EventQueue; //導入依賴的package包/類
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();
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:24,代碼來源:Hiero.java

示例4: testMemoryRelease

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

示例5: startAnnotation

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

示例6: preferenceChange

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

示例7: shelve

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

示例8: setWaitCursor

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

示例9: main

import java.awt.EventQueue; //導入依賴的package包/類
/**
 * 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();
            }
        }
    });
}
 
開發者ID:hisener,項目名稱:bbm487s2017g1,代碼行數:24,代碼來源:LoginWindow.java

示例10: getJFXBadge

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

示例11: executeTestCase

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

示例12: main

import java.awt.EventQueue; //導入依賴的package包/類
/**
 * 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();
			}
		}
	});
}
 
開發者ID:Streus,項目名稱:Project-SADS,代碼行數:20,代碼來源:MainWindow.java

示例13: run

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

示例14: awtRequest

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

示例15: invokeAndWaitLowPriority

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


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