public void processDataConversionRequests() {
if (EventQueue.isdispatchThread()) {
AppContext appContext = AppContext.getAppContext();
getToolkitThreadBlockedHandler().lock();
try {
Runnable dataConverter =
(Runnable)appContext.get(DATA_CONVERTER_KEY);
if (dataConverter != null) {
dataConverter.run();
appContext.remove(DATA_CONVERTER_KEY);
}
} finally {
getToolkitThreadBlockedHandler().unlock();
}
}
}
项目:incubator-netbeans
文件:AWTTask.java
@Override
public boolean waitFinished(long milliseconds) throws InterruptedException {
if (EventQueue.isdispatchThread()) {
PENDING.remove(this);
run();
return true;
} else {
WAKE_UP.wakeUp();
synchronized (this) {
if (isFinished()) {
return true;
}
wait(milliseconds);
return isFinished();
}
}
}
项目:jdk8u-jdk
文件:DataTransferer.java
public void processDataConversionRequests() {
if (EventQueue.isdispatchThread()) {
AppContext appContext = AppContext.getAppContext();
getToolkitThreadBlockedHandler().lock();
try {
Runnable dataConverter =
(Runnable)appContext.get(DATA_CONVERTER_KEY);
if (dataConverter != null) {
dataConverter.run();
appContext.remove(DATA_CONVERTER_KEY);
}
} finally {
getToolkitThreadBlockedHandler().unlock();
}
}
}
项目:trashjam2017
文件:Hiero.java
public void close () {
final long endTime = System.currentTimeMillis();
new Thread(new Runnable() {
public void run () {
if (endTime - startTime < minMillis) {
addMouseListener(new MouseAdapter() {
public void mousepressed (MouseEvent evt) {
dispose();
}
});
try {
Thread.sleep(minMillis - (endTime - startTime));
} catch (InterruptedException ignored) {
}
}
EventQueue.invokelater(new Runnable() {
public void run () {
dispose();
}
});
}
},"Splash").start();
}
项目:incubator-netbeans
文件:CodeTemplatesTest.java
@RandomlyFails
public void testMemoryRelease() throws Exception { // Issue #147984
org.netbeans.junit.Log.enableInstances(Logger.getLogger("TIMER"),"CodeTemplateInsertHandler",Level.FInesT);
JEditorPane pane = new JEditorPane();
NbeditorKit kit = new NbeditorKit();
pane.setEditorKit(kit);
Document doc = pane.getDocument();
assertTrue(doc instanceof BaseDocument);
CodeTemplateManager mgr = CodeTemplateManager.get(doc);
String templateText = "Test with parm ";
CodeTemplate ct = mgr.createTemporary(templateText + " ${a}");
ct.insert(pane);
assertEquals(templateText + " a",doc.getText(0,doc.getLength()));
// Send Enter to stop editing
KeyEvent enterKeyEvent = new KeyEvent(pane,KeyEvent.KEY_pressed,EventQueue.getMostRecentEventTime(),KeyEvent.VK_ENTER,KeyEvent.CHAR_UNDEFINED);
SwingUtilities.processKeyBindings(enterKeyEvent);
// CT editing should be finished
org.netbeans.junit.Log.assertInstances("CodeTemplateInsertHandler instances not GCed");
}
项目:incubator-netbeans
文件:VCSAnnotationProviderTestCase.java
private void startAnnotation(final Set<FileObject> files) {
EventQueue.invokelater(new Runnable() {
@Override
public void run() {
lastEvent = System.currentTimeMillis();
long time = System.currentTimeMillis();
for (FileObject fo : files) {
String name = fo.getNameExt();
name = VersioningAnnotationProvider.getDefault().annotateNameHtml(name,Collections.singleton(fo));
annotationsLabels.put(fo,name);
Image image = ImageUtilities.assignToolTipToImage(VCSAnnotationProviderTestCase.IMAGE,fo.getNameExt());
ImageUtilities.getimageToolTip(image);
image = VersioningAnnotationProvider.getDefault().annotateIcon(image,Collections.singleton(fo));
annotationsIcons.put(fo,image);
}
time = System.currentTimeMillis() - time;
if (time > 500) {
ex = new Exception("Annotation takes more than 200ms");
}
}
});
}
项目:incubator-netbeans
文件:CommitPanel.java
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
if (evt.getKey().startsWith(HgModuleConfig.PROP_COMMIT_EXCLUSIONS)) {
Runnable inAWT = new Runnable() {
@Override
public void run() {
commitTable.dataChanged();
listenerSupport.fireversioningEvent(EVENT_SETTINGS_CHANGED);
}
};
// this can be called from a background thread - e.g. change of exclusion status in Versioning view
if (EventQueue.isdispatchThread()) {
inAWT.run();
} else {
EventQueue.invokelater(inAWT);
}
}
}
项目:incubator-netbeans
文件:ShelveChangesAction.java
@NbBundle.Messages({
"MSG_ShelveAction.noModifications.text=There are no local modifications to shelve.","LBL_ShelveAction.noModifications.title=No Local Modifications"
})
public void shelve (File repository,File[] roots) {
if (Git.getInstance().getFileStatusCache().listFiles(roots,File@R_621_404[email protected]_MODIFIED_HEAD_VS_WORKING).length == 0) {
// no local changes found
EventQueue.invokelater(new Runnable() {
@Override
public void run () {
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),Bundle.MSG_ShelveAction_noModifications_text(),Bundle.LBL_ShelveAction_noModifications_title(),JOptionPane.@R_621_4045@ION_MESSAGE);
}
});
return;
}
GitShelveChangesSupport supp = new GitShelveChangesSupport(repository);
if (supp.open()) {
RequestProcessor rp = Git.getInstance().getRequestProcessor(repository);
supp.startAsync(rp,repository,roots);
}
}
项目:incubator-netbeans
文件:Utils.java
/**
* Switches the wait cursor on the NetBeans glasspane of/on
*
* @param on
*/
public static void setWaitCursor(final boolean on) {
Runnable r = new Runnable() {
@Override
public void run() {
JFrame mainWindow = (JFrame) WindowManager.getDefault().getMainWindow();
mainWindow
.getGlasspane()
.setCursor(Cursor.getPredefinedCursor(
on ?
Cursor.WAIT_CURSOR :
Cursor.DEFAULT_CURSOR));
mainWindow.getGlasspane().setVisible(on);
}
};
if(EventQueue.isdispatchThread()) {
r.run();
} else {
EventQueue.invokelater(r);
}
}
项目:bbm487s2017g1
文件:LoginWindow.java
/**
* Launch the application.
*/
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch (ClassNotFoundException | InstantiationException | illegalaccessexception | UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(LoginWindow.class.getName()).log(java.util.logging.Level.SEVERE,null,ex);
JOptionPane.showMessageDialog(null,ex.getMessage());
}
EventQueue.invokelater(new Runnable() {
public void run() {
try {
LoginWindow window = new LoginWindow();
window.frmlibraryBookLoan.setVisible(true);
} catch (Exception e) {
e.printstacktrace();
}
}
});
}
项目:incubator-netbeans
文件:JFXProjectIconAnnotator.java
/**
* Gets the badge
* @return badge or null if badge icon does not exist
*/
@NullUnkNown
private Image getJFXBadge() {
Image img = badgeCache.get();
if (img == null) {
if(!EventQueue.isdispatchThread()) {
img = ImageUtilities.loadImage(JFX_BADGE_PATH);
badgeCache.set(img);
} else {
final Runnable runLoadIcon = new Runnable() {
@Override
public void run() {
badgeCache.set(ImageUtilities.loadImage(JFX_BADGE_PATH));
cs.fireChange();
}
};
final RequestProcessor RP = new RequestProcessor(JFXProjectIconAnnotator.class.getName());
RP.post(runLoadIcon);
}
}
return img;
}
项目:openjdk-jdk10
文件:ProgressBarMemoryLeakTest.java
private static void executeTestCase(String lookAndFeelString) throws Exception{
if (tryLookAndFeel(lookAndFeelString)) {
EventQueue.invokeAndWait( new Runnable() {
@Override
public void run() {
showUI();
}
} );
EventQueue.invokeAndWait( new Runnable() {
@Override
public void run() {
disposeUI();
}
} );
Util.generateOOME();
JProgressBar progressBar = sProgressBar.get();
if ( progressBar != null ) {
throw new RuntimeException( "Progress bar (using L&F: " + lookAndFeelString + ") should have been GC-ed" );
}
}
}
项目:Project-SADS
文件:MainWindow.java
/**
* Launch the application.
*/
public static void main(String[] args)
{
if(args.length > 0)
DEBUG = args[0].equalsIgnoreCase("debug");
EventQueue.invokelater(new Runnable() {
public void run() {
try {
MainWindow window = new MainWindow();
window.frmStringSequenceAnalyzer.setVisible(true);
} catch (Exception e) {
e.printstacktrace();
}
}
});
}
项目:incubator-netbeans
文件:DiffViewManager.java
@Override
public void run() {
diffSerial = cachedDiffSerial;
computeSecondHighlights();
if (diffSerial != cachedDiffSerial) {
return;
}
computeFirstHighlights();
if (diffSerial == cachedDiffSerial) {
EventQueue.invokelater(new Runnable() {
@Override
public void run() {
master.getEditorPane1().fireHilitingChanged();
master.getEditorPane2().fireHilitingChanged();
}
});
}
}
项目:incubator-netbeans
文件:ListViewWithUpTest.java
private static <T> T awtRequest(final Callable<T> call) throws Exception {
final atomicreference<T> value = new atomicreference<T>();
final Exception[] exc = new Exception[1];
EventQueue.invokeAndWait(new Runnable() {
@Override
public void run() {
try {
value.set(call.call());
} catch (Exception ex) {
exc[0] = ex;
}
}
});
if (exc[0] != null) throw exc[0];
return value.get();
}
项目:incubator-netbeans
文件:EventLock.java
/**
* Similar to {@link EventQueue#invokeAndWait} but posts the event at the same
* priority as paint requests,to avoid bad visual artifacts.
*/
static void invokeAndWaitLowPriority(RWLock m,Runnable r)
throws InterruptedException,InvocationTargetException {
Toolkit t = Toolkit.getDefaultToolkit();
EventQueue q = t.getSystemEventQueue();
Object lock = new PaintPriorityEventLock();
InvocationEvent ev = new PaintPriorityEvent(m,t,r,lock,true);
synchronized (lock) {
q.postEvent(ev);
lock.wait();
}
Exception e = ev.getException();
if (e != null) {
throw new InvocationTargetException(e);
}
}
public void handleNotification(
final Notification notification,Object handback) {
EventQueue.invokelater(new Runnable() {
public void run() {
if (notification instanceof MBeanServerNotification) {
ObjectName mbean =
((MBeanServerNotification) notification).getMBeanName();
if (notification.getType().equals(
MBeanServerNotification.REGISTRATION_NOTIFICATION)) {
tree.addMBeanToView(mbean);
} else if (notification.getType().equals(
MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
tree.removeMBeanFromView(mbean);
}
}
}
});
}
项目:incubator-netbeans
文件:RepositoryRevision.java
@Override
protected void perform () {
Map<File,GitFileInfo> files;
try {
files = getLog().getModifiedFiles();
} catch (GitException ex) {
GitClientExceptionHandler.notifyException(ex,true);
files = Collections.<File,GitFileInfo>emptyMap();
}
final List<Event> logEvents = prepareEvents(files);
if (!isCanceled()) {
EventQueue.invokelater(new Runnable() {
@Override
public void run () {
if (!isCanceled()) {
events.clear();
dummyEvents.clear();
events.addAll(logEvents);
eventsInitialized = true;
currentSearch = null;
support.firePropertyChange(RepositoryRevision.PROP_EVENTS_CHANGED,new ArrayList<Event>(events));
}
}
});
}
}
项目:incubator-netbeans
文件:UpdateResults.java
public UpdateResults(List<FileUpdateInfo> results,SVNUrl url,String contextdisplayName) {
this.results = results;
String time = DateFormat.getTimeInstance().format(new Date());
setName(NbBundle.getMessage(UpdateResults.class,"CTL_UpdateResults_Title",SvnUtils.decodetoString(url),contextdisplayName,time)); // NOI18N
setLayout(new BorderLayout());
if (results.size() == 0) {
add(new NoContentPanel(NbBundle.getMessage(UpdateResults.class,"MSG_NoFilesUpdated"))); // NOI18N
} else {
final UpdateResultsTable urt = new UpdateResultsTable();
Subversion.getInstance().getRequestProcessor().post(new Runnable () {
public void run() {
final UpdateResultNode[] nodes = createNodes();
EventQueue.invokelater(new Runnable() {
public void run() {
urt.setTableModel(nodes);
add(urt.getComponent());
}
});
}
});
}
}
项目:SnakeAndLadder
文件:Main.java
/**
* Launch the application.
*/
public static void main(String[] args) { //ekhane dhukar drkr nai :/
EventQueue.invokelater(new Runnable() {
public void run() {
try {
Main frame = new Main();
frame.setVisible(true);
} catch (Exception e) {
e.printstacktrace();
}
}
});
}
@SuppressWarnings("unchecked")
public EventQueueDelegateFromMap(Map<String,Map<String,Object>> objectMap) {
Map<String,Object> methodMap = objectMap.get("afterdispatch");
afterdispatchEventArgument = (AWTEvent[]) methodMap.get("event");
afterdispatchHandleArgument = (Object[]) methodMap.get("handle");
afterdispatchCallable = (Callable<Void>) methodMap.get("method");
methodMap = objectMap.get("beforedispatch");
beforedispatchEventArgument = (AWTEvent[]) methodMap.get("event");
beforedispatchCallable = (Callable<Object>) methodMap.get("method");
methodMap = objectMap.get("getNextEvent");
getNextEventEventQueueArgument =
(EventQueue[]) methodMap.get("eventQueue");
getNextEventCallable = (Callable<AWTEvent>) methodMap.get("method");
}
项目:Recaf
文件:SwingUI.java
public void init(LaunchParams params) {
EventQueue.invokelater(new Runnable() {
public void run() {
try {
frame.setDefaultCloSEOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(params.getSize());
frame.setJMenuBar(menuBar);
frame.getContentPane().setLayout(new BorderLayout(0,0));
setupMenu();
setupPane();
} catch (Exception exception) {
Recaf.INSTANCE.logging.error(exception);
}
}
});
}
项目:incubator-netbeans
文件:FavoritesTest.java
@RandomlyFails // got empty list of nodes in NB-Core-Build #3603
public void testSelectWithAdditionExisting() throws Exception {
RootsTest.clearBareFavoritesTabInstance();
TopComponent win = RootsTest.getBareFavoritesTabInstance();
assertNull(win);
fav.add(file);
assertTrue(fav.isInFavorites(file));
fav.selectWithAddition(file);
win = RootsTest.getBareFavoritesTabInstance();
assertNotNull(win);
assertTrue(win.isOpened());
assertTrue(fav.isInFavorites(file));
EventQueue.invokeAndWait(new Runnable() { // Favorites tab EM refreshed in invokelater,we have to wait too
public void run() {
ExplorerManager man = ((ExplorerManager.Provider) RootsTest.getBareFavoritesTabInstance()).getExplorerManager();
assertNotNull(man);
Node[] nodes = man.getSelectednodes();
assertEquals(Arrays.toString(nodes),1,nodes.length);
assertEquals(TEST_TXT,nodes[0].getName());
}
});
}
项目:incubator-netbeans
文件:SearchHistoryAction.java
public static void openSearch (final File repository,final File root,final String contextName,final int lineNumber) {
final String title = NbBundle.getMessage(SearchHistoryTopComponent.class,"LBL_SearchHistoryTopComponent.title",contextName);
final RepositoryInfo info = RepositoryInfo.getInstance(repository);
EventQueue.invokelater(new Runnable() {
@Override
public void run () {
SearchHistoryTopComponent tc = new SearchHistoryTopComponent(repository,info,root,new SearchHistoryTopComponent.DiffResultsViewFactory() {
@Override
DiffResultsView createDiffResultsView(SearchHistoryPanel panel,List<RepositoryRevision> results) {
return new DiffResultsViewForLine(panel,results,lineNumber);
}
});
tc.setdisplayName(title);
tc.open();
tc.requestActive();
tc.search(true);
tc.activateDiffView(true);
}
});
}
项目:incubator-netbeans
文件:VCSCommitPanel.java
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
if (evt.getKey().startsWith(PROP_COMMIT_EXCLUSIONS)) { // XXX - need setting
Runnable inAWT = new Runnable() {
@Override
public void run() {
commitTable.dataChanged();
listenerSupport.fireversioningEvent(EVENT_SETTINGS_CHANGED);
}
};
// this can be called from a background thread - e.g. change of exclusion status in Versioning view
if (EventQueue.isdispatchThread()) {
inAWT.run();
} else {
EventQueue.invokelater(inAWT);
}
}
}
项目:incubator-netbeans
文件:SelectInstallationPanel.java
@NbBundle.Messages({
"MSG_Detecting_Wait=Detecting installations,please wait..."
})
private void initList() {
installationList.setListData(new Object[]{
Bundle.MSG_Detecting_Wait()
});
installationList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
installationList.setEnabled(false);
RequestProcessor.getDefault().post(new Runnable() {
@Override
public void run() {
final List<Installation> installations =
InstallationManager.detectAllInstallations();
EventQueue.invokelater(new Runnable() {
@Override
public void run() {
updateListForDetectedInstallations(installations);
}
});
}
});
}
项目:incubator-netbeans
文件:ReporterResultTopComponent.java
@Override
public void run() {
if (EventQueue.isdispatchThread()){
try {
loadPage(new URL(urlStr),show);
} catch (MalformedURLException ex) {
handleIOException(urlStr,ex);
}
}else{
String userName = new ExceptionsSettings().getUserName();
if (userName != null && !"".equals(userName)) { //NOI18N
urlStr = NbBundle.getMessage(ReporterResultTopComponent.class,"userNameURL") + userName;
} else {
String userId = Installer.findIdentity();
if (userId != null) {
urlStr = NbBundle.getMessage(ReporterResultTopComponent.class,"userIdURL") + userId;
}
}
if (urlStr == null) {
return; // XXX prompt to log in?
}
EventQueue.invokelater(this);
}
}
项目:incubator-netbeans
文件:TimableEventQueueTest.java
public void testdispatchEvent() throws Exception {
class Slow implements Runnable {
private int ok;
@Override
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Exceptions.printstacktrace(ex);
}
ok++;
}
}
Slow slow = new Slow();
EventQueue.invokeAndWait(slow);
EventQueue.invokeAndWait(slow);
TimableEventQueue.RP.shutdown();
TimableEventQueue.RP.awaitTermination(3,TimeUnit.SECONDS);
assertEquals("called",2,slow.ok);
if (!log.toString().contains("too much time in AWT thread")) {
fail("There shall be warning about too much time in AWT thread:\n" + log);
}
}
项目:incubator-netbeans
文件:AsynchChildren.java
/**
* Notify this AsynchChildren that it should reconstruct its children,* calling <code>provider.asynchCreateKeys()</code> and setting the
* keys to that. Call this method if the list of child objects is kNown
* or likely to have changed.
* @param immediate If true,the keys are updated synchronously from the
* calling thread. Set this to true only if you kNow that updating
* the keys will <i>not</i> be an expensive or time-consuming operation.
*/
public void refresh(boolean immediate) {
immediate &= !EventQueue.isdispatchThread();
logger.log (Level.FINE,"Refresh on {0} immediate {1}",new Object[] //NOI18N
{ this,immediate });
if (logger.isLoggable(Level.FInesT)) {
logger.log (Level.FInesT,"Refresh: ",new Exception()); //NOI18N
}
if (immediate) {
boolean done;
List <T> keys = new LinkedList <T> ();
do {
done = factory.createKeys(keys);
} while (!done);
setKeys (keys);
} else {
task.schedule (0);
}
}
/**
* Draws a black triangle-shaped shadow with the vertix in the middle of the
* Rectangle <code> from</code> and the base centred in the middle of the
* Rectangle <code>to</code>. The base width is determined by the parameter
* <code>defaultWidth</code>. the base at <code>base</code>.
*
* @param vertix
* @param base
*/
private void draw(Rectangle from,Rectangle to) {
GraphicsJLabel label = this;
EventQueue.invokelater(new Runnable() {
@Override
public void run() {
xx[0] = from.getX() + from.getWidth() / 2;
yy[0] = from.getY() + from.getHeight() / 2;
xx[1] = to.getX() + to.getWidth() / 2;
yy[1] = to.getY() + to.getHeight() / 2;
double alpha = atan(Math.abs((xx[1] - xx[0]) / (yy[1] - yy[0])));
xx[2] = xx[1] + DEFAULT_WIDTH * cos(alpha);
yy[2] = yy[1] + DEFAULT_WIDTH * sin(alpha);
label.updateUI();
}
});
}
项目:tttclass
文件:JavavcCameraTest.java
public static void main(String[] args) throws Exception,InterruptedException {
EventQueue.invokelater(new Runnable()
{
public void run()
{
try
{
JavavcCameraTest gabber = new JavavcCameraTest(0);
}
catch (Exception e)
{
e.printstacktrace();
}
}
});
}
private void updatetoolbar(final FileObject file) {
RP.post(new Runnable() {
@Override
public void run() {
//getActiveProviders() must not be called in EDT as it might do some I/Os
final Collection<CssstylesPanelProvider> activeProviders = getActiveProviders(file);
EventQueue.invokelater(new Runnable() {
@Override
public void run() {
updatetoolbar(file,activeProviders);
}
});
}
});
}
项目:incubator-netbeans
文件:UnshelveChangesAction.java
private void initializePatches () {
panel.cmbPatches.setModel(new DefaultComboBoxModel(new String[] { LOADING_PATCHES }));
validate();
Utils.postParallel(new Runnable() {
@Override
public void run () {
final List<Patch> patches = PatchStorage.getInstance().getPatches();
EventQueue.invokelater(new Runnable() {
@Override
public void run () {
panel.cmbPatches.setModel(new DefaultComboBoxModel(patches.toArray(new Patch[patches.size()])));
if (!patches.isEmpty()) {
panel.cmbPatches.setSelectedindex(0);
}
}
});
}
},0);
}
项目:incubator-netbeans
文件:ExplorerActionsImpl.java
public final void waitFinished() {
ActionStateUpdater u = actionStateUpdater;
synchronized (this) {
u = actionStateUpdater;
}
if (u == null) {
return;
}
u.waitFinished();
if (EventQueue.isdispatchThread()) {
u.run();
} else {
try {
EventQueue.invokeAndWait(u);
} catch (Exception ex) {
Exceptions.printstacktrace(ex);
}
}
}
项目:incubator-netbeans
文件:OpenRepositoryAction.java
@Override
public void actionPerformed (ActionEvent event) {
final File f = new FileChooserBuilder(OpenRepositoryAction.class).setDirectoriesOnly(true)
.setApproveText(Bundle.CTL_OpenRepository_okButton())
.setAccessibleDescription(Bundle.CTL_OpenRepository_ACSD())
.showOpenDialog();
if (f == null) {
return;
}
Utils.postParallel(new Runnable () {
@Override
public void run() {
final File repository = Git.getInstance().getRepositoryRoot(f);
if (repository != null) {
GitRepositories.getInstance().add(repository,true);
EventQueue.invokelater(new Runnable() {
@Override
public void run () {
GitRepositoryTopComponent rtc = GitRepositoryTopComponent.findInstance();
rtc.open();
rtc.requestActive();
rtc.selectRepository(repository);
}
});
}
}
},0);
}
@Override
protected void createPasteTypes(Transferable t,List<PasteType> s) {
assertFalse("Don't block AWT",EventQueue.isdispatchThread());
if (pasteTypes != null) {
s.addAll(pasteTypes);
}
}
项目:Sensors
文件:Interface.java
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokelater(new Runnable() {
public void run() {
try {
Interface window = new Interface();
window.frame.setVisible(true);
} catch (Exception e) {
e.printstacktrace();
}
}
});
}
项目:openjdk-jdk10
文件:ProgressMonitorEscapeKeyPress.java
public static void main(String[] args) throws Exception {
createTestUI();
monitor = new ProgressMonitor(frame,"Progress",100);
robotthread = new TestThread();
robotthread.start();
for (counter = 0; counter <= 100; counter += 10) {
Thread.sleep(1000);
EventQueue.invokeAndWait(new Runnable() {
@Override
public void run() {
if (!monitor.isCanceled()) {
monitor.setProgress(counter);
System.out.println("Progress bar is in progress");
}
}
});
if (monitor.isCanceled()) {
break;
}
}
disposeTestUI();
if (counter >= monitor.getMaximum()) {
throw new RuntimeException("Escape key did not cancel the ProgressMonitor");
}
}
项目:jijimaku
文件:TextAreaOutputStream.java
synchronized void append(String val) {
values.add(val);
if (queue) {
queue = false;
EventQueue.invokelater(this);
}
}
private void configurationsListChanged(@NullAllowed Collection<? extends ProjectConfiguration> configs) {
LOGGER.log(Level.FINER,"configurationsListChanged: {0}",configs);
ProjectConfigurationProvider<?> _pcp;
synchronized (this) {
_pcp = pcp;
}
if (configs == null) {
EventQueue.invokelater(new Runnable() {
public @Override void run() {
configListCombo.setModel(EMPTY_MODEL);
configListCombo.setEnabled(false); // possibly redundant,but just in case
}
});
} else {
final DefaultComboBoxModel model = new DefaultComboBoxModel(configs.toArray());
if (_pcp != null && _pcp.hasCustomizer()) {
model.addElement(CUSTOMIZE_ENTRY);
}
EventQueue.invokelater(new Runnable() {
public @Override void run() {
configListCombo.setModel(model);
configListCombo.setEnabled(true);
}
});
}
if (_pcp != null) {
activeConfigurationChanged(getActiveConfiguration(_pcp));
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。