List of usage examples for javax.swing SwingUtilities invokeLater
public static void invokeLater(Runnable doRun)
From source file:com.jbombardier.console.panels.ProcessTelemetryPanel.java
/** * Create the panel.//from ww w .j av a 2 s . c o m */ public ProcessTelemetryPanel() { setBorder(new TitledBorder(null, "Process Telemetry", TitledBorder.LEADING, TitledBorder.TOP, null, null)); setLayout(new MigLayout("ins 0", "[grow]", "[grow]")); stackedBarCPU = ChartBuilder.startStackedBar().setTitle("CPU").setYAxisLabel("Percentage cpu") .setXAxisLabel("").setYAxisLabel("").setOrientation(PlotOrientation.HORIZONTAL).setYMaximum(100) .toChart(); stackedBarMemory = ChartBuilder.startStackedBar().setTitle("Memory").setYAxisLabel("MBytes") .setXAxisLabel("").setOrientation(PlotOrientation.HORIZONTAL).toChart(); add(stackedBarCPU.getComponent(), "cell 0 0,grow"); add(stackedBarMemory.getComponent(), "cell 1 0,grow"); xyCPU = (XYTimeChartPanel) ChartBuilder.startXY().setTitle("CPU").setYAxisLabel("Percentage cpu used") .toChart(); xyMemory = (XYTimeChartPanel) ChartBuilder.startXY().setTitle("Memory").setYAxisLabel("MBytes free") .toChart(); add(xyCPU.getComponent(), "cell 0 1,grow"); add(xyMemory.getComponent(), "cell 1 1,grow"); timer = TimerUtils.every("ProcessTelemetryPanel-Updater", 500, TimeUnit.MILLISECONDS, new Runnable() { public void run() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { updateInternal2(); } }); } }); }
From source file:com.jidesoft.spring.richclient.docking.view.JideAbstractView.java
/** * Activates this view taking care of EDT issues * *///from w ww . ja v a 2s. co m public void activateView() { if (SwingUtilities.isEventDispatchThread()) { getActiveWindow().getPage().showView(getId()); } else { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { getActiveWindow().getPage().showView(getId()); } }); } }
From source file:br.univali.ps.ui.telas.TelaPrincipal.java
private void instalarObservadorJanela() { JFrame frame = Lancador.getJFrame(); if (frame == null) return;//from w w w.ja v a 2 s.com frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { fecharAplicativo(); } @Override public void windowOpened(WindowEvent e) { Configuracoes configuracoes = Configuracoes.getInstancia(); if (configuracoes.isExibirDicasInterface()) { SwingUtilities.invokeLater(() -> { PortugolStudio.getInstancia().getTelaDicas().setVisible(true); }); } LOGGER.log(Level.INFO, "Janela principal aberta!"); } }); Lancador.getJFrame().addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { if (abrindo) { abrindo = false; // Por enquanto o Andr pediu para desativar esta verificao, ela s estar disponvel // no final do ano //verificarAtualizacaoCritica(); if (Configuracoes.getInstancia().isExibirTutorialUso()) { //TODO: criar e executar tutorial de uso antes de iniciar o Portugol dispararProcessosAbertura(); } else { dispararProcessosAbertura(); } } } }); }
From source file:com.eviware.soapui.impl.rest.panels.component.RestResourceEditor.java
public RestResourceEditor(final RestResource editingRestResource, MutableBoolean updating) { super(editingRestResource.getFullPath()); this.editingRestResource = editingRestResource; this.updating = updating; setName(REST_RESOURCE_EDITOR_TEXT_FIELD); if (isResourceLonely(editingRestResource)) { getDocument().addDocumentListener(new LonelyDocumentListener()); addFocusListener(new FocusListener() { public void focusLost(FocusEvent e) { scanForTemplateParameters(editingRestResource); removeMatrixParameters(); }/* w w w.j av a2 s .c o m*/ /** * Matrix parameters should not be added directly on the rest resource. * The parameter editor should be used. Hence they are removed from the rest resource editor * text field at this time. */ private void removeMatrixParameters() { setText(getText().split(";")[0]); } public void focusGained(FocusEvent e) { } }); } else { Color originalBackground = getBackground(); Border originalBorder = getBorder(); setEditable(false); setBackground(originalBackground); setBorder(originalBorder); setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); mouseListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { final RestResource focusedResource = new RestResourceFinder(editingRestResource) .findResourceAt(lastSelectedPosition); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { openPopup(focusedResource); } }); } }; addMouseListener(mouseListener); addCaretListener(new CaretListener() { @Override public void caretUpdate(final CaretEvent e) { lastSelectedPosition = e.getDot(); } }); } }
From source file:net.sf.jclal.gui.view.components.chart.ExternalBasicChart.java
/** * * @param args NOT IN USE./*from w w w. j a v a 2s. co m*/ */ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { ExternalBasicChart demo = new ExternalBasicChart("Active learning " + "process", "", "Number of labeled instances"); demo.pack(); RefineryUtilities.centerFrameOnScreen(demo); demo.setVisible(true); } }); }
From source file:Main.java
/** * Fires a {@link ActionListener}. This is useful for firing * {@link ApplicationAction}s to show blocking dialog. This can be called * on and off the EDT.//from w w w .j a v a2 s . c o m * * @param listener the listener to fire. * @param evt the action event to fire. * @param modifiers the modifier keys held down during this action. * @see ActionEvent#ActionEvent(Object, int, String, long, int) */ public static void fireAction(final ActionListener listener, final ActionEvent evt) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { fireAction(listener, evt); } }); return; } listener.actionPerformed(evt); }
From source file:com.limegroup.gnutella.gui.LicenseWindow.java
/** * Notification that a license has been verified. * * Rebuilds the details panel to match the new status. *//*from w ww . j a va 2 s . c o m*/ public void licenseVerified(License license) { if (license == LICENSE) { SwingUtilities.invokeLater(new Runnable() { public void run() { buildDetails(); } }); } if (LISTENER != null) LISTENER.licenseVerified(license); }
From source file:org.yccheok.jstock.gui.BuyPortfolioChartJDialog.java
/** Creates new form BuyPortfolioChartJDialog */ public BuyPortfolioChartJDialog(java.awt.Frame parent, boolean modal, BuyPortfolioTreeTableModelEx portfolioTreeTableModel, PortfolioRealTimeInfo portfolioRealTimeInfo, DividendSummary dividendSummary) { super(parent, GUIBundle.getString("BuyPortfolioChartJDialog_BuySummary"), modal); this.initCodeToTotalDividend(dividendSummary); initComponents();//from w w w . j a v a 2s . c o m this.portfolioTreeTableModel = portfolioTreeTableModel; this.portfolioRealTimeInfo = portfolioRealTimeInfo; final JFreeChart freeChart; final int lastSelectedBuyPortfolioChartIndex = JStock.instance().getJStockOptions() .getLastSelectedBuyPortfolioChartIndex(); if (lastSelectedBuyPortfolioChartIndex < this.jComboBox1.getItemCount() && lastSelectedBuyPortfolioChartIndex < cNames.length && lastSelectedBuyPortfolioChartIndex >= 0) { freeChart = createChart(cNames[lastSelectedBuyPortfolioChartIndex]); // Put it in next queue, so that it won't trigger jComBox1's event // when this.chartPanel is not ready yet. SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jComboBox1.setSelectedIndex(lastSelectedBuyPortfolioChartIndex); } }); } else { freeChart = createChart(cNames[0]); } org.yccheok.jstock.charting.Utils.applyChartTheme(freeChart); chartPanel = new ChartPanel(freeChart, true, true, true, true, true); getContentPane().add(chartPanel, java.awt.BorderLayout.CENTER); }
From source file:com.igormaznitsa.sciareto.ui.editors.mmeditors.NoteEditor.java
public NoteEditor(@Nonnull final String text) { initComponents();/*ww w. j a v a 2 s .c o m*/ this.setPreferredSize(new Dimension(640, 480)); this.editorPane.setText(text); this.addAncestorListener(new AncestorListener() { @Override public void ancestorAdded(@Nonnull final AncestorEvent event) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { editorPane.requestFocusInWindow(); updateCaretPos(); } }); } @Override public void ancestorRemoved(@Nonnull final AncestorEvent event) { } @Override public void ancestorMoved(@Nonnull final AncestorEvent event) { } }); this.editorPane.addCaretListener(new CaretListener() { @Override public void caretUpdate(@Nonnull final CaretEvent e) { updateCaretPos(); } }); this.wrapping = Wrapping.NONE; updateBottomPanel(); }