Java Code Examples for java.awt.EventQueue

The following are top voted examples for showing how to use java.awt.EventQueue. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OpenJSharp   File: DataTransferer.java   View source code 8 votes vote down vote up
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();
        }
    }
}
 
Example 2
Project: incubator-netbeans   File: AWTTask.java   View source code 7 votes vote down vote up
@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();
        }
    }
}
 
Example 3
Project: jdk8u-jdk   File: DataTransferer.java   View source code 7 votes vote down vote up
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();
        }
    }
}
 
Example 4
Project: trashjam2017   File: Hiero.java   View source code 6 votes vote down vote up
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();
}
 
Example 5
Project: incubator-netbeans   File: CodeTemplatesTest.java   View source code 6 votes vote down vote up
@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");
}
 
Example 6
Project: incubator-netbeans   File: VCSAnnotationProviderTestCase.java   View source code 6 votes vote down vote up
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");
            }
        }     
    });
}
 
Example 7
Project: incubator-netbeans   File: CommitPanel.java   View source code 6 votes vote down vote up
@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);
        }
    }
}
 
Example 8
Project: incubator-netbeans   File: ShelveChangesAction.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 9
Project: incubator-netbeans   File: Utils.java   View source code 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 10
Project: bbm487s2017g1   File: LoginWindow.java   View source code 6 votes vote down vote up
/**
 * 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();
            }
        }
    });
}
 
Example 11
Project: incubator-netbeans   File: JFXProjectIconAnnotator.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 12
Project: openjdk-jdk10   File: ProgressBarMemoryLeakTest.java   View source code 6 votes vote down vote up
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" );
    }
  }
}
 
Example 13
Project: Project-SADS   File: MainWindow.java   View source code 6 votes vote down vote up
/**
 * 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();
			}
		}
	});
}
 
Example 14
Project: incubator-netbeans   File: DiffViewManager.java   View source code 6 votes vote down vote up
@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();
            }
        });
    }
}
 
Example 15
Project: incubator-netbeans   File: ListViewWithUpTest.java   View source code 6 votes vote down vote up
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();
}
 
Example 16
Project: incubator-netbeans   File: EventLock.java   View source code 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 17
Project: OpenJSharp   File: MBeansTab.java   View source code 6 votes vote down vote up
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);
                }
            }
        }
    });
}
 
Example 18
Project: incubator-netbeans   File: RepositoryRevision.java   View source code 6 votes vote down vote up
@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));
                }
            }
        });
    }
}
 
Example 19
Project: incubator-netbeans   File: UpdateResults.java   View source code 6 votes vote down vote up
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());
                    }
                });
            }
        });
    }
}
 
Example 20
Project: SnakeAndLadder   File: Main.java   View source code 6 votes vote down vote up
/**
 * 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();
			}
		}
	});
}
 
Example 21
Project: OpenJSharp   File: SwingUtilities3.java   View source code 6 votes vote down vote up
@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");
}
 
Example 22
Project: Recaf   File: SwingUI.java   View source code 6 votes vote down vote up
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);
			}
		}
	});
}
 
Example 23
Project: incubator-netbeans   File: FavoritesTest.java   View source code 6 votes vote down vote up
@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());
        }

    });
}
 
Example 24
Project: incubator-netbeans   File: SearchHistoryAction.java   View source code 6 votes vote down vote up
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);
        }
    });
}
 
Example 25
Project: incubator-netbeans   File: VCSCommitPanel.java   View source code 6 votes vote down vote up
@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);
        }
    }
}
 
Example 26
Project: incubator-netbeans   File: SelectInstallationPanel.java   View source code 6 votes vote down vote up
@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);
                }
            });
        }
    });
}
 
Example 27
Project: incubator-netbeans   File: ReporterResultTopComponent.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 28
Project: incubator-netbeans   File: TimableEventQueueTest.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 29
Project: incubator-netbeans   File: AsynchChildren.java   View source code 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 30
Project: Progetto-B   File: GraphicsJLabel.java   View source code 6 votes vote down vote up
/**
 * 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();
        }
    });

}
 
Example 31
Project: tttclass   File: JavavcCameraTest.java   View source code 6 votes vote down vote up
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();
			}
		}
	});
	
}
 
Example 32
Project: incubator-netbeans   File: CssStylesPanel.java   View source code 6 votes vote down vote up
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);
                }

            });
        }

    });
}
 
Example 33
Project: incubator-netbeans   File: UnshelveChangesAction.java   View source code 6 votes vote down vote up
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);
}
 
Example 34
Project: incubator-netbeans   File: ExplorerActionsImpl.java   View source code 6 votes vote down vote up
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);
        }
    }
}
 
Example 35
Project: incubator-netbeans   File: OpenRepositoryAction.java   View source code 5 votes vote down vote up
@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);
}
 
Example 36
Project: incubator-netbeans   File: ExplorerActionsImplTest.java   View source code 5 votes vote down vote up
@Override
protected void createPasteTypes(Transferable t, List<PasteType> s) {
    assertFalse("Don't block AWT", EventQueue.isDispatchThread());
    if (pasteTypes != null) {
        s.addAll(pasteTypes);
    }
}
 
Example 37
Project: Sensors   File: Interface.java   View source code 5 votes vote down vote up
/**
 * 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();
			}
		}
	});
}
 
Example 38
Project: openjdk-jdk10   File: ProgressMonitorEscapeKeyPress.java   View source code 5 votes vote down vote up
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");
        }
    }
 
Example 39
Project: jijimaku   File: TextAreaOutputStream.java   View source code 5 votes vote down vote up
synchronized void append(String val) {
  values.add(val);
  if (queue) {
    queue = false;
    EventQueue.invokeLater(this);
  }
}
 
Example 40
Project: incubator-netbeans   File: ActiveConfigAction.java   View source code 5 votes vote down vote up
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));
    }
}