Java Code Examples for javax.swing.SwingUtilities#invokeLater()
The following examples show how to use
javax.swing.SwingUtilities#invokeLater() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaObjectsView.java From visualvm with GNU General Public License v2.0 | 6 votes |
private synchronized void setPreset(Preset preset) { if (preset == Preset.DOMINATORS) { final Heap heap = context.getFragment().getHeap(); if (!DataType.RETAINED_SIZE.valuesAvailable(heap)) { SwingUtilities.invokeLater(new Runnable() { public void run() { dominatorsRefresher = new Runnable() { public void run() { if (getPreset() == Preset.DOMINATORS) objectsView.reloadView(); dominatorsRefresher = null; } }; DataType.RETAINED_SIZE.notifyWhenAvailable(heap, dominatorsRefresher); DataType.RETAINED_SIZE.computeValues(heap, null); } }); } } this.preset = preset; objectsView.setViewName(preset.toString()); tbType.setVisible(preset == Preset.GC_ROOTS); if (tbType.isSelected() && !tbType.isVisible()) tbClasses.setSelected(true); else if (!skipReload) objectsView.reloadView(); }
Example 2
Source File: JPopover.java From pumpernickel with MIT License | 6 votes |
@Override public void stateChanged(ChangeEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JPopover<?> p = ref.get(); if (p != null) { p.refreshVisibility(false); } else { MenuSelectionManager.defaultManager() .removeChangeListener( MenuSelectionManagerListener.this); } } }); }
Example 3
Source File: GlyphGutter.java From netbeans with Apache License 2.0 | 6 votes |
public @Override void preferenceChange(PreferenceChangeEvent evt) { EditorUI eui = editorUI; JTextComponent c = eui == null ? null : eui.getComponent(); Rectangle rect = c == null ? null : c.getVisibleRect(); if (rect != null && rect.width == 0) { if (SwingUtilities.isEventDispatchThread()) { resize(); } else { SwingUtilities.invokeLater( new Runnable() { public @Override void run() { resize(); } } ); } } }
Example 4
Source File: RocPlot.java From rtg-tools with BSD 2-Clause "Simplified" License | 6 votes |
private void loadData(ArrayList<File> files, ArrayList<String> names, Box2D initialZoom) { final StringBuilder sb = new StringBuilder(); final ProgressBarDelegate progress = new ProgressBarDelegate(mProgressBar); for (int i = 0; i < files.size(); ++i) { final File f = files.get(i); final String name = names.get(i); try { loadFile(f, name, progress); } catch (final IOException | NoTalkbackSlimException e1) { sb.append(f.getPath()).append('\n'); } } progress.done(); if (sb.length() > 0) { JOptionPane.showMessageDialog(mMainPanel.getTopLevelAncestor(), "Some files could not be loaded:\n" + sb.toString() + "\n", "Invalid ROC File", JOptionPane.ERROR_MESSAGE); } if (initialZoom == null) { SwingUtilities.invokeLater(() -> mZoomPP.getDefaultZoomAction().actionPerformed(new ActionEvent(this, 0, "LoadComplete"))); } else { SwingUtilities.invokeLater(() -> mZoomPP.setZoom(initialZoom)); } }
Example 5
Source File: ActionWithProgress.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
/** * Called if an error occurrs. Can be overridden. SHows dialog by default. * * @param e the exception thrown. */ public void onError( Exception e ) { e.printStackTrace(); String localizedMessage = e.getLocalizedMessage(); if (localizedMessage == null) { localizedMessage = e.getMessage(); } if (localizedMessage == null || localizedMessage.trim().length() == 0) { localizedMessage = "An undefined error was thrown. Please send the below trace to your technical contact:\n"; localizedMessage += ExceptionUtils.getStackTrace(e); } String _localizedMessage = localizedMessage; SwingUtilities.invokeLater(new Runnable(){ public void run() { JOptionPane.showMessageDialog(parent, _localizedMessage, "ERROR", JOptionPane.ERROR_MESSAGE); } }); }
Example 6
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 5 votes |
public void invokePaste() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { pasteEntityFromClipboard(); } }); }
Example 7
Source File: RegisterTabCloseChangeListener_GeneralSingleVetoable.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * The main method for <code>this</code> sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(() -> { SubstanceCortex.GlobalScope.setSkin(new BusinessBlackSteelSkin()); new RegisterTabCloseChangeListener_GeneralSingleVetoable().setVisible(true); }); }
Example 8
Source File: TaskRewardLevelAction.java From gameserver with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable(){ public void run() { MainPanel.getInstance().setCenterPanel(TaskRewardLevelPanel.getInstance()); } }); }
Example 9
Source File: LoadedSnapshot.java From netbeans with Apache License 2.0 | 5 votes |
public void setFile(File file) { this.file = file; saved = true; SwingUtilities.invokeLater(new Runnable() { public void run() { if (SnapshotResultsWindow.hasSnapshotWindow(LoadedSnapshot.this)) SnapshotResultsWindow.get(LoadedSnapshot.this).refreshTabName(); } }); }
Example 10
Source File: CertificateController.java From Spark with Apache License 2.0 | 5 votes |
/** * Resizes certificate table to preferred width. */ public void resizeColumnWidth(JTable table) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { final TableColumnModel columnModel = table.getColumnModel(); final int maxWidth = table.getParent().getWidth(); columnModel.getColumn(1).setPreferredWidth(80); columnModel.getColumn(2).setPreferredWidth(60); columnModel.getColumn(0).setPreferredWidth(maxWidth - 140); } }); }
Example 11
Source File: HeapWalker.java From netbeans with Apache License 2.0 | 5 votes |
void createRetainedFragment(Instance instance) { SwingUtilities.invokeLater(new Runnable() { public void run() { // TODO: Open new tab or select existing one } }); }
Example 12
Source File: IncrementalLoadJob.java From ghidra with Apache License 2.0 | 5 votes |
private void flush(IncrementalUpdatingAccumulator accumulator) { // // Acquire the update manager lock so that it doesn't send out any events while we are // giving it the data we just finished loading. // synchronized (updateManager.getSynchronizingLock()) { // push the data to the update manager... accumulator.flushData(); // // ...Add a listener to know when we can tell our listeners that loading is finished. // // (Add the listener later so that we don't get notified of any pending events from // the update manager that may have already been posted by the time we have // acquired the lock above.) // // Also, we are guaranteed that the flush() call will not call to the Swing thread // before we add our listener due to the fact that we currently hold a lock on the // updateManager, which is required to notify the listeners. The basic sequence is: // // -Flush starts a job thread (or uses the running one) // -We have the update manager's lock, so it blocks on jobDone() if that happens before // this code can return // -We push the invokeLater() // -We release the lock // -A block on jobDone() can now complete as we release the lock // -jobDone() will notify listeners in an invokeLater(), which puts it behind ours // SwingUtilities.invokeLater( () -> updateManager.addThreadedTableListener(IncrementalLoadJob.this)); } }
Example 13
Source File: bug4337267.java From hottub with GNU General Public License v2.0 | 5 votes |
void testNonTextComponentPlain() { System.out.println("testNonTextComponentHTML:"); JLabel label1 = new JLabel(); injectComponent(p1, label1, false); label1.setText(shaped); JLabel label2 = new JLabel(); injectComponent(p2, label2, true); label2.setText(text); window.repaint(); printq = new JComponent[] { label1, label2 }; SwingUtilities.invokeLater(printComponents); SwingUtilities.invokeLater(compareRasters); }
Example 14
Source File: LobbyGameTableModel.java From triplea with GNU General Public License v3.0 | 5 votes |
private void removeGame(final String gameId) { SwingUtilities.invokeLater( () -> { if (gameId == null) { return; } final LobbyGameListing gameToRemove = findGame(gameId); if (gameToRemove != null) { final int index = gameList.indexOf(gameToRemove); gameList.remove(gameToRemove); fireTableRowsDeleted(index, index); } }); }
Example 15
Source File: TestApplet.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void destroy(){ SwingUtilities.invokeLater(new Runnable(){ public void run(){ removeAll(); System.out.println("applet:destroyStart"); } }); app.stop(true); System.out.println("applet:destroyEnd"); }
Example 16
Source File: MainForm.java From cncgcodecontroller with MIT License | 5 votes |
@Override public void sendCNCSommands(CNCCommand[] commands) { SwingUtilities.invokeLater(() -> { jTabbedPane.setSelectedComponent(jPanelCNCMilling); jPanelCNCMilling.sendCNCCommands(commands); }); }
Example 17
Source File: DeferredCharacterComboBoxModel.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void focusLost(FocusEvent e) { // Temporary focus lost means something like the drop-down has // got focus if (e.isTemporary()) { return; } SwingUtilities.invokeLater(() -> commitSelectedItem(selectedItem)); }
Example 18
Source File: Test8019180.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws InterruptedException { SwingUtilities.invokeLater(new Test8019180()); LATCH.await(); }
Example 19
Source File: AllocTableView.java From netbeans with Apache License 2.0 | 4 votes |
private void setData(final int _nTrackedItems, final String[] _classNames, final int[] _nTotalAllocObjects, final long[] _totalAllocObjectsSize, final boolean diff) { // TODO: show classes with zero instances in live results! SwingUtilities.invokeLater(new Runnable() { public void run() { if (tableModel != null) { nTrackedItems = _nTrackedItems; classNames = new ClientUtils.SourceCodeSelection[_classNames.length]; for (int i = 0; i < classNames.length; i++) classNames[i] = new ClientUtils.SourceCodeSelection(_classNames[i], Wildcards.ALLWILDCARD, null); nTotalAllocObjects = _nTotalAllocObjects; totalAllocObjectsSize = _totalAllocObjectsSize; long totalObjects = 0; long _totalObjects = 0; long totalBytes = 0; long _totalBytes = 0; for (int i = 0; i < nTrackedItems; i++) { if (diff) { totalObjects = Math.max(totalObjects, nTotalAllocObjects[i]); _totalObjects = Math.min(_totalObjects, nTotalAllocObjects[i]); totalBytes = Math.max(totalBytes, totalAllocObjectsSize[i]); _totalBytes = Math.min(_totalBytes, totalAllocObjectsSize[i]); } else { totalObjects += nTotalAllocObjects[i]; totalBytes += totalAllocObjectsSize[i]; } } if (diff) { renderers[0].setMaxValue(Math.max(Math.abs(totalBytes), Math.abs(_totalBytes))); renderers[1].setMaxValue(Math.max(Math.abs(totalObjects), Math.abs(_totalObjects))); } else { renderers[0].setMaxValue(totalBytes); renderers[1].setMaxValue(totalObjects); } renderers[0].setDiffMode(diff); renderers[1].setDiffMode(diff); tableModel.fireTableDataChanged(); } } }); }
Example 20
Source File: OverviewViewSupport.java From visualvm with GNU General Public License v2.0 | 4 votes |
public void dataChanged(DataChangeEvent<Snapshot> event) { SwingUtilities.invokeLater(new Runnable() { public void run() { updateSavedData(); } }); }