javax.swing.SwingUtilities#invokeLater ( )源码实例Demo

下面列出了javax.swing.SwingUtilities#invokeLater ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: visualvm   文件: JavaObjectsView.java
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();
}
 
源代码2 项目: netbeans   文件: GlyphGutter.java
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();
                    }
                }
            );
        }
    }
}
 
源代码3 项目: hortonmachine   文件: ActionWithProgress.java
/**
 * 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);
        }
    });
}
 
源代码4 项目: rtg-tools   文件: RocPlot.java
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));
  }
}
 
源代码5 项目: pumpernickel   文件: JPopover.java
@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);
			}
		}
	});
}
 
源代码6 项目: ghidra   文件: IncrementalLoadJob.java
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));
	}
}
 
源代码7 项目: pcgen   文件: DeferredCharacterComboBoxModel.java
@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));
}
 
源代码8 项目: cncgcodecontroller   文件: MainForm.java
@Override
public void sendCNCSommands(CNCCommand[] commands) {
    SwingUtilities.invokeLater(() -> {
        jTabbedPane.setSelectedComponent(jPanelCNCMilling);
        jPanelCNCMilling.sendCNCCommands(commands);
    });
}
 
源代码9 项目: MikuMikuStudio   文件: TestApplet.java
@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");
}
 
源代码10 项目: triplea   文件: LobbyGameTableModel.java
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);
        }
      });
}
 
源代码11 项目: hottub   文件: bug4337267.java
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);
}
 
源代码12 项目: jaamsim   文件: GUIFrame.java
public void invokePaste() {
	SwingUtilities.invokeLater(new Runnable() {
		@Override
		public void run() {
			pasteEntityFromClipboard();
		}
	});
}
 
源代码13 项目: netbeans   文件: HeapWalker.java
void createRetainedFragment(Instance instance) {
    SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                // TODO: Open new tab or select existing one
            }
        });
}
 
源代码14 项目: Spark   文件: CertificateController.java
/**
    * 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);
           }
       });
   }
 
源代码15 项目: netbeans   文件: LoadedSnapshot.java
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();
            }
        });
}
 
源代码16 项目: gameserver   文件: TaskRewardLevelAction.java
@Override
public void actionPerformed(ActionEvent e) {
	SwingUtilities.invokeLater(new Runnable(){
		public void run() {
			MainPanel.getInstance().setCenterPanel(TaskRewardLevelPanel.getInstance());
		}
	});
}
 
/**
 * 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);
    });
}
 
源代码18 项目: netbeans   文件: AllocTableView.java
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();
            }
        }
    });
}
 
源代码19 项目: jdk8u-dev-jdk   文件: Test8019180.java
public static void main(String[] args) throws InterruptedException {
    SwingUtilities.invokeLater(new Test8019180());
    LATCH.await();
}
 
源代码20 项目: visualvm   文件: OverviewViewSupport.java
public void dataChanged(DataChangeEvent<Snapshot> event) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() { updateSavedData(); }
    });
}