本文整理汇总了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();
}
}
}
示例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();
}
}
}
示例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();
}
示例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");
}
示例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");
}
}
});
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
});
}
示例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;
}
示例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" );
}
}
}
示例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();
}
}
});
}
示例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();
}
});
}
}
示例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();
}
示例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);
}
}