List of usage examples for javax.swing SwingUtilities invokeLater
public static void invokeLater(Runnable doRun)
From source file:net.sf.nmedit.nomad.core.NomadPlugin.java
public void startApplication() throws Exception { Log log = LogFactory.getLog(getClass()); if (log != null) logOsInfo(log);// w w w.j a v a2 s .com final NomadLoader loader = new NomadLoader(); nomad = loader.createNomad(NomadPlugin.this); SwingUtilities.invokeLater(new Runnable() { public void run() { // invoke on event dispatch thread nomad.setupUI(); loader.initServices(); nomad.setupMenu(); // after service so they can install custom menu items nomad.getWindow().invalidate(); nomad.getWindow().validate(); nomad.getWindow().setVisible(true); } }); }
From source file:fxts.stations.transport.tradingapi.processors.QuoteProcessor.java
public void process(ITransportable aTransportable) { final TradingServerSession aTradingServerSession = TradingServerSession.getInstance(); final Quote aQuote = (Quote) aTransportable; mLogger.debug("aQuote = " + aQuote); final MainFrame mainFrame = TradeApp.getInst().getMainFrame(); if (aQuote.getQuoteID().startsWith(FXCMCommandType.REQUOTE_PREFIX)) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { ShowQuoteDialog mDlg = new ShowQuoteDialog(mainFrame); mDlg.setExpirationDate(aQuote.getValidUntilTime().toDate()); mDlg.setCurrency(aQuote.getInstrument().getSymbol()); mDlg.setBuyPrice(aQuote.getBidPx()); mDlg.setSellPrice(aQuote.getOfferPx()); int result = mainFrame.showDialog(mDlg); ITransportable amsg; if (result == ShowQuoteDialog.BUY || result == ShowQuoteDialog.SELL) { amsg = MessageGenerator.generateAcceptOrder(aQuote.getQuoteID(), "accept requote"); } else { amsg = MessageGenerator.generatePassResponse(aQuote.getQuoteID()); }//from ww w. j ava 2 s. co m aTradingServerSession.send(amsg); } catch (Exception e) { e.printStackTrace(); } } }); } else { // RFQ SwingUtilities.invokeLater(new Runnable() { private ShowQuoteDialog mDlg = new ShowQuoteDialog(mainFrame); public void run() { try { if (aQuote.getValidUntilTime().toDate().after(new Date())) { mDlg.setExpirationDate(aQuote.getValidUntilTime().toDate()); mDlg.setCurrency(aQuote.getInstrument().getSymbol()); mDlg.setBuyPrice(aQuote.getOfferPx()); mDlg.setSellPrice(aQuote.getBidPx()); int res = mainFrame.showDialog(mDlg); if (res == ShowQuoteDialog.BUY) { OrderSingle orderSingle = MessageGenerator.generateOpenOrder(aQuote.getQuoteID(), aQuote.getOfferPx(), aQuote.getAccount(), aQuote.getOrderQty(), SideFactory.BUY, aQuote.getInstrument().getSymbol(), null); aTradingServerSession.send(orderSingle); } else if (res == ShowQuoteDialog.SELL) { OrderSingle orderSingle = MessageGenerator.generateOpenOrder(aQuote.getQuoteID(), aQuote.getBidPx(), aQuote.getAccount(), aQuote.getOrderQty(), SideFactory.SELL, aQuote.getInstrument().getSymbol(), null); aTradingServerSession.send(orderSingle); } } QuoteResponse qr = MessageGenerator.generatePassResponse(aQuote.getQuoteRespID()); qr.setInstrument(aQuote.getInstrument()); mLogger.debug("Removing the Quote"); aTradingServerSession.send(qr); } catch (Exception e) { e.printStackTrace(); } } }); } }
From source file:io.github.thred.climatetray.ClimateTrayUtils.java
protected static void consumeUpdateFailed() { SwingUtilities.invokeLater(() -> { ClimateTrayUtils.dialogWithCloseAndProxySettings(null, "Request failed", Message.error("The request for version updates failed.\n\n" + "This usually indicates, that the application cannot contact the website with the " + "build information on GitHub. You may wish to update your proxy settings, now.")); });// ww w . ja v a 2 s. co m }
From source file:ru.codemine.pos.service.device.barcodescanner.BarcodeScannerSerialPortListener.java
@Override public void serialEvent(SerialPortEvent ev) { if (ev.getEventType() != SerialPort.LISTENING_EVENT_DATA_AVAILABLE) return;/* w ww. ja v a 2 s .c o m*/ int bytesAvaible = ev.getSerialPort().bytesAvailable(); byte[] buffer = new byte[bytesAvaible]; ev.getSerialPort().readBytes(buffer, bytesAvaible); dataStr += new String(buffer); if (dataStr.endsWith("\n")) { final String dataStrTransfer = dataStr; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { int tabIndex = mainWindow.getActiveTabIndex(); boolean inputBlocked = mainWindow.isBarcodeInputBlocked(); if (tabIndex == 0 && !inputBlocked) salesPanel.addProductByBarcode(dataStrTransfer.replace("\n", "")); } }); dataStr = ""; } }
From source file:URLMonitorPanel.java
public void isAlive(final boolean b) { SwingUtilities.invokeLater(new Runnable() { public void run() { status.setBackground(b ? Color.GREEN : Color.RED); status.repaint();/* w w w .j av a2 s. c om*/ } }); }
From source file:de.atomfrede.tools.evalutation.util.DialogUtil.java
public void showError(final Exception ex) { SwingUtilities.invokeLater(new Runnable() { @Override//ww w . jav a 2 s .c om public void run() { new ExceptionDialog(frame, ex).setVisible(true); } }); }
From source file:org.usfirst.frc.team2084.smartdashboard.extensions.BetterCompass.java
@Override public void init() { // needleType.add("Arrow", 0); // needleType.add("Line", 1); // needleType.add("Long", 2); // needleType.add("Pin", 3); // needleType.add("Plum", 4); // needleType.add("Pointer", 5); // needleType.add("Ship", 6); // needleType.add("Wind", 7); // needleType.add("Arrow Line", 8); // needleType.add("Middle Pin", 9); // needleType.setDefault("Arrow Line"); SwingUtilities.invokeLater(() -> { setLayout(new BorderLayout()); compass = new CompassPlot(getDataset()); compass.setSeriesNeedle(8);/*from w w w.j av a 2s .c o m*/ // propertyChanged(needleType); compass.setSeriesPaint(0, Color.RED); compass.setSeriesOutlinePaint(0, Color.RED); JFreeChart chart = new JFreeChart(getFieldName(), JFreeChart.DEFAULT_TITLE_FONT, compass, false); chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(250, 150)); propertyChanged(circumference); propertyChanged(ringColor); add(chartPanel, BorderLayout.CENTER); revalidate(); repaint(); }); }
From source file:components.TextSamplerDemo.java
public static void main(String[] args) { //Schedule a job for the event dispatching thread: //creating and showing this application's GUI. SwingUtilities.invokeLater(new Runnable() { public void run() { //Turn off metal's use of bold fonts UIManager.put("swing.boldMetal", Boolean.FALSE); createAndShowGUI();//from w ww .j ava 2 s . c o m } }); }
From source file:com.przemo.probabilities.gui.SimulatorPanel.java
public void simulate() { if (runOrStop) { getSimulationParameters();/* ww w . j av a 2 s .co m*/ sw = new BettingGuiSimulator(createSimulator(), probability) { @Override protected void process(List chunks) { //chunks is a List<Map<Integer.Double>> (account) chartData = (Map<Integer, Double>) chunks.get(chunks.size() - 1); SimulatorPanel.this.simulationStepForAccountTaken(); } }; SwingUtilities.invokeLater(() -> { initCharts(); }); sw.execute(); runOrStop = false; } else { if (sw != null) { sw.cancel(true); } runOrStop = true; } }
From source file:com.roche.iceboar.progressview.ProgressUpdater.java
public void update(final ProgressEvent event) { final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); SwingUtilities.invokeLater(new Runnable() { public void run() { if (events.contains(event)) { events.remove(event);/*from ww w . j av a2s . c o m*/ progressBar.setValue(progressBar.getValue() + 1); progressBar.setString(calculatePercent()); if (event.getMessage() != null) { messageLabel.setText(event.getMessage()); } } else { String message = "Not found event: \"" + event.getEventName() + "\" " + prepareStackTrace(stackTrace); System.out.println(message); throw new RuntimeException(message); } } }); }