List of usage examples for javax.swing SwingUtilities invokeLater
public static void invokeLater(Runnable doRun)
From source file:org.nbheaven.sqe.codedefects.dashboard.controlcenter.panels.Statistics.java
private void updateView() { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(new Runnable() { public void run() { updateView();//from ww w .j a v a 2 s . c om } }); return; } assert SwingUtilities.isEventDispatchThread(); // Update per project view first perProjectDataSet.clear(); for (QualityProvider qualityProvider : SQEUtilities.getProviders()) { String providerName = qualityProvider.getDisplayName(); perProjectDataSet.addValue(0, CodeDefectSeverity.ERROR, providerName); perProjectDataSet.addValue(0, CodeDefectSeverity.WARNING, providerName); perProjectDataSet.addValue(0, CodeDefectSeverity.INFO, providerName); } if (null != activeProject) { Collection<? extends QualitySession> sessions = activeProject.getLookup() .lookupAll(QualitySession.class); for (QualitySession session : sessions) { if (null == session.getResult()) { continue; } QualityResultStatistic statistic = session.getResult().getLookup() .lookup(QualityResultStatistic.class); if (null != statistic) { String providerName = session.getProvider().getDisplayName(); perProjectDataSet.addValue(statistic.getCodeDefectCount(CodeDefectSeverity.ERROR), CodeDefectSeverity.ERROR, providerName); perProjectDataSet.addValue(statistic.getCodeDefectCount(CodeDefectSeverity.WARNING), CodeDefectSeverity.WARNING, providerName); perProjectDataSet.addValue(statistic.getCodeDefectCount(CodeDefectSeverity.INFO), CodeDefectSeverity.INFO, providerName); } } } Statistics.this.invalidate(); Statistics.this.revalidate(); Statistics.this.repaint(); }
From source file:gda.images.GUI.CmuCameraDisplayPanel.java
@Override public void configure() { //logger.info("Cmu Camera Panel config called"); samplePanel = new RTPCameraClient(); samplePanel.setPreferredSize(ImageSize); samplePanel.setMinimumSize(ImageSize); samplePanel.setMaximumSize(ImageSize); samplePanel.getImageModifier().setDisplayCrossHair(true); samplePanel.addMouseListener(new MouseListener() { @Override/*from w w w . j a v a 2s .c o m*/ public void mouseClicked(MouseEvent mevt) { //logger.info("mouse clicked at " + mevt.getLocationOnScreen()); //samplePanel.setCentre(mevt.getLocationOnScreen()); if (mevt.isControlDown()) { Point p = mevt.getPoint(); x = p.x; y = p.y; samplePanel.getImageModifier().setCentre(p); save(); } //samplePanel.revalidate(); } @Override public void mouseEntered(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseReleased(MouseEvent arg0) { // TODO Auto-generated method stub } }); try { config = LocalParameters.getXMLConfiguration(); } catch (ConfigurationException e) { logger.error("unable to configure beam centre values ", e); } catch (IOException e) { logger.error("unable to read beam centre values ", e); } this.load(); //samplePanel.setDisplayCrossHair(true); //samplePanel.setDisplayBeamSize(true); // samplePanel.getImageModifier().setCentre(new Point(x, y)); //samplePanel.setBeamSize(new Point(50, 50), new Point(200, 200)); this.setLayout(new BorderLayout()); this.add(samplePanel, BorderLayout.CENTER); this.add(getButtonPanel(), BorderLayout.SOUTH); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { CmuCameraDisplayPanel.this.add(samplePanel); //samplePanel.setXScale(0.9); //samplePanel.setYScale(1.1); //samplePanel.setDisplayScale(true); //samplePanel.start(); } }); videoReceiver.addImageListener(this); }
From source file:net.sf.housekeeper.swing.CategoriesView.java
public void onApplicationEvent(ApplicationEvent e) { if (e instanceof HousekeeperEvent) { final HousekeeperEvent le = (HousekeeperEvent) e; if (le.getEventType() == HousekeeperEvent.CATEGORIES_MODIFIED) { LOG.debug("Received CATEGORIES_MODIFIED event"); SwingUtilities.invokeLater(new Runnable() { public void run() { refresh();/*ww w . j av a2 s . com*/ } }); } } }
From source file:edu.umich.robot.Application.java
private void runGui(final Config config) { SwingTools.initializeLookAndFeel();//from www. j a v a2 s. com SwingUtilities.invokeLater(new Runnable() { public void run() { new GuiApplication(config); } }); }
From source file:com.intuit.tank.tools.debugger.SelectDialog.java
public void filter(final long timeValue) { new Thread(new Runnable() { @Override/*from w ww . j ava 2 s.co m*/ public void run() { try { Thread.sleep(200); if (timeValue == timeClicked) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { List<SELECTION_TYPE> filtered = new ArrayList<SELECTION_TYPE>(); for (SELECTION_TYPE obj : items) { if (StringUtils.isBlank(filterField.getText()) || StringUtils .containsIgnoreCase(obj.toString(), filterField.getText().trim())) { filtered.add(obj); } } list.setListData(filtered.toArray()); list.repaint(); } }); } else { System.out.println("skipping..."); } } catch (InterruptedException e) { e.printStackTrace(); } } }).start(); }
From source file:gate.Main.java
/** Run the user interface. */ protected static void runGui() throws GateException { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); // initialise the library and load user CREOLE directories try {/* ww w. j a v a 2s. c o m*/ Gate.init(); } catch (Throwable t) { log.error("Problem while initialising GATE", t); int selection = JOptionPane.showOptionDialog(null, "Error during initialisation:\n" + t.toString() + "\nDo you still want to start GATE?", "GATE", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, new String[] { "Cancel", "Start anyway" }, "Cancel"); if (selection != 1) { System.exit(1); } } //create the main frame, show it SwingUtilities.invokeLater(new Runnable() { @Override public void run() { GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice().getDefaultConfiguration(); //this needs to run before any GUI component is constructed. applyUserPreferences(); //all the defaults tables have been updated; build the GUI frame = MainFrame.getInstance(gc); if (DEBUG) Out.prln("constructing GUI"); // run the GUI frame.setTitleChangable(true); frame.setTitle(name + " " + version + " build " + build); // Set title from Java properties String title = System.getProperty(GateConstants.TITLE_JAVA_PROPERTY_NAME); if (title != null) { frame.setTitle(title); } // if frame.setTitleChangable(false); // Set icon from Java properties // iconName could be absolute or "gate:/img/..." String iconName = System.getProperty(GateConstants.APP_ICON_JAVA_PROPERTY_NAME); if (iconName != null) { try { frame.setIconImage(Toolkit.getDefaultToolkit().getImage(new URL(iconName))); } catch (MalformedURLException mue) { log.warn("Could not load application icon.", mue); } } // if // Validate frames that have preset sizes frame.validate(); // Center the window Rectangle screenBounds = gc.getBounds(); Dimension screenSize = screenBounds.getSize(); Dimension frameSize = frame.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); frame.setVisible(true); //load session if required and available; //do everything from a new thread. Runnable runnable = new Runnable() { @Override public void run() { try { File sessionFile = Gate.getUserSessionFile(); if (sessionFile.exists()) { MainFrame.lockGUI("Loading saved session..."); PersistenceManager.loadObjectFromFile(sessionFile); } } catch (Exception e) { log.warn("Failed to load session data", e); } finally { MainFrame.unlockGUI(); } } }; Thread thread = new Thread(Thread.currentThread().getThreadGroup(), runnable, "Session loader"); thread.setPriority(Thread.MIN_PRIORITY); thread.start(); } }); registerCreoleUrls(); }
From source file:de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart.MainM.java
public MainM(final boolean showMainFrame, String applicationName, String[] args, String[] addon, String addPluginFile) {//from www . j a v a2 s .c o m this(applicationName, args, addon, new DBEsplashScreen(applicationName, "", new RunnableWithSplashScreenReference() { private SplashScreenInterface ss; @Override public void run() { if (showMainFrame) { ClassLoader cl = this.getClass().getClassLoader(); String path = this.getClass().getPackage().getName().replace('.', '/'); ImageIcon icon = new ImageIcon(cl.getResource(path + "/vanted_logo.png")); final MainFrame mainFrame = MainFrame.getInstance(); if (icon != null && mainFrame != null) mainFrame.setIconImage(icon.getImage()); if (mainFrame == null) System.err.println("Internal Error: MainFrame is NULL"); else { Thread t = new Thread(new Runnable() { @Override public void run() { long waitTime = 0; long start = System.currentTimeMillis(); do { if (ErrorMsg.getAppLoadingStatus() == ApplicationStatus.ADDONS_LOADED) break; try { Thread.sleep(50); } catch (InterruptedException e) { } waitTime = System.currentTimeMillis() - start; } while (waitTime < 2000); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { ss.setVisible(false); mainFrame.setVisible(true); } }); } }, "wait for add-on initialization"); t.start(); } } } @Override public void setSplashscreenInfo(SplashScreenInterface ss) { this.ss = ss; } }) { }, addPluginFile, showMainFrame); }
From source file:JXButtonPanel.java
public static void main(String[] args) throws Exception { SwingUtilities.invokeLater(new Runnable() { public void run() { new JXButtonPanelDemo().setVisible(true); }/* w ww.j a va 2 s .co m*/ }); }
From source file:com.aw.swing.mvp.grid.GridManager.java
public void refreshValuesCounter() { SwingUtilities.invokeLater(new Runnable() { public void run() { Object value = ""; GridFunction gridFunction = bndSJTable.getGridFunction(); if (gridFunction != null) { value = gridFunction.execute(); value = gridFunction.getLabel() + " " + value + " | "; }// w w w. j av a 2 s. co m numRecords.setText(value + "Total de Registros: " + bndSJTable.getValues().size() + " "); } }); }
From source file:ch.zhaw.iamp.rct.Controller.java
/** * Shows the {@link GrammarWindow}. If there is no instance yet, one will be * created./*from w ww .ja va 2 s . c o m*/ */ public void showGrammarWindow() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (!isGrammarWindowVisible()) { grammarWindow = new GrammarWindow(); grammarWindow.setController(App.controller); Components.setIcons(grammarWindow); grammarWindow.setVisible(true); grammarWindow.restoreHelpWindows(); } grammarWindow.requestFocus(); grammarWindow.toFront(); } }); }