當前位置: 首頁>>代碼示例>>Java>>正文


Java SwingUtilities.isEventDispatchThread方法代碼示例

本文整理匯總了Java中javax.swing.SwingUtilities.isEventDispatchThread方法的典型用法代碼示例。如果您正苦於以下問題:Java SwingUtilities.isEventDispatchThread方法的具體用法?Java SwingUtilities.isEventDispatchThread怎麽用?Java SwingUtilities.isEventDispatchThread使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.SwingUtilities的用法示例。


在下文中一共展示了SwingUtilities.isEventDispatchThread方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: maybeInvokeLater

import javax.swing.SwingUtilities; //導入方法依賴的package包/類
/** Invokes a runnable on the event queue if the current thread is not the
 * event queue, or synchronously if it is.  If it is invoked synchronously,
 * the event queue will be drained before this method returns, so any events
 * generated by the runnable have been processed.  If a runtime exception
 * is thrown while the passed-in runnable is running, it will be rethrown
 * by this method, in the calling thread.  */
protected static void maybeInvokeLater(Runnable run) throws Exception {
    WrapperRunnable wrap = new WrapperRunnable(run);
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeAndWait(wrap);
    } else {
        if (run instanceof EventGenerator) {
            AWTEvent evt = ((EventGenerator)run).getEvent();
            ((Component) evt.getSource()).dispatchEvent(evt);
        } else {
            wrap.run();
        }
    }
    wrap.throwAnyExceptions();
    sleep();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:ExtTestCase.java

示例2: resourceLoaded

import javax.swing.SwingUtilities; //導入方法依賴的package包/類
/**
 * If the resource just loaded is a tool (according to the creole
 * register) then see if it publishes any actions and if so, add them
 * to the menu in the appropriate places.
 */
@Override
public void resourceLoaded(CreoleEvent e) {
  final Resource res = e.getResource();

  if(res instanceof DocumentExporter) {
    Runnable runnable = new Runnable() {
      @Override
      public void run() {
        addExporter((DocumentExporter)res);
      }
    };
    
    if(SwingUtilities.isEventDispatchThread()) {
      runnable.run();
    } else {
      try {
        SwingUtilities.invokeAndWait(runnable);
      } catch(Exception ex) {
        log.warn("Exception registering document exporter", ex);
      }
    }
  }
}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:29,代碼來源:DocumentExportMenu.java

示例3: disconnectInEDT

import javax.swing.SwingUtilities; //導入方法依賴的package包/類
private void disconnectInEDT(final String disconnectMsg, final boolean error) {
    Runnable disconnectRunnable = new Runnable() {

        @Override
        public void run() {
            disconnect(disconnectMsg, error);
        }
    };
    if (SwingUtilities.isEventDispatchThread()) {
        disconnectRunnable.run();
    } else {
        try {
            SwingUtilities.invokeAndWait(disconnectRunnable);
        } catch (Exception ex) {
            throw new FubarException(ex);
        }
    }
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:19,代碼來源:YaposhEngine.java

示例4: dragEnded

import javax.swing.SwingUtilities; //導入方法依賴的package包/類
@Override
public void dragEnded() {
	if (SwingUtilities.isEventDispatchThread()) {
		plotConfigurationTreeScrollPane.setBorder(DROP_ENDED_BORDER);
		plotConfigurationTree.setBackground(Color.WHITE);
	} else {
		SwingUtilities.invokeLater(new Runnable() {

			@Override
			public void run() {
				plotConfigurationTreeScrollPane.setBorder(DROP_ENDED_BORDER);
				plotConfigurationTree.setBackground(Color.WHITE);
			}
		});
	}

}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:18,代碼來源:ChartConfigurationPanel.java

示例5: setBody

import javax.swing.SwingUtilities; //導入方法依賴的package包/類
public void setBody (final String msg, final String text) {
    if (SwingUtilities.isEventDispatchThread ()) {
        setBodyInEQ (msg, text);
    } else {
        SwingUtilities.invokeLater (new Runnable () {
            @Override
            public void run () {
                setBodyInEQ (msg, text);
            }
        });
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:OperationPanel.java

示例6: setProgressComponent

import javax.swing.SwingUtilities; //導入方法依賴的package包/類
void setProgressComponent (final JLabel detail, final JComponent progressComponent) {
    if (SwingUtilities.isEventDispatchThread ()) {
        setProgressComponentInAwt (detail, progressComponent);
    } else {
        SwingUtilities.invokeLater (new Runnable () {
            @Override
            public void run () {
                setProgressComponentInAwt (detail, progressComponent);
            }
        });
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:PluginManagerUI.java

示例7: waitAndSetProgressComponents

import javax.swing.SwingUtilities; //導入方法依賴的package包/類
public void waitAndSetProgressComponents (final JLabel mainLabel, final JComponent progressComponent, final JLabel detailLabel) {
    if (SwingUtilities.isEventDispatchThread ()) {
        setProgressComponents (mainLabel, progressComponent, detailLabel);
    } else {
        SwingUtilities.invokeLater (new Runnable () {
            @Override
            public void run () {
                setProgressComponents (mainLabel, progressComponent, detailLabel);
            }
        });
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:OperationPanel.java

示例8: initLater

import javax.swing.SwingUtilities; //導入方法依賴的package包/類
private void initLater(){
    if (ProviderUtil.isValidServerInstanceOrNone(project)){
        if(SwingUtilities.isEventDispatchThread()){
            connectDatasources();
        } else {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    connectDatasources();
                }
            });
        }
    }        
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:PersistenceUnitWizardPanelDS.java

示例9: setupComponents

import javax.swing.SwingUtilities; //導入方法依賴的package包/類
public void setupComponents() {
	if (SwingUtilities.isEventDispatchThread()) {
		setupComponentsNow();
	} else {
		SwingUtilities.invokeLater(new Runnable() {

			@Override
			public void run() {
				setupComponentsNow();
			}
		});
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:14,代碼來源:PropertyPanel.java

示例10: getUrlString

import javax.swing.SwingUtilities; //導入方法依賴的package包/類
/**
 * Load selected root from Swing structures (from arbitrary thread).
 * @return null on failure
 */
private String getUrlString() throws InterruptedException {        
    if(!repositoryPanel.urlComboBox.isEditable()) {
        Object selection = repositoryPanel.urlComboBox.getSelectedItem();
        if(selection != null) {
            return selection.toString().trim();    
        }
        return "";    
    } else {
        final String[] svnUrl = new String[1];
        try {
            Runnable awt = new Runnable() {
                @Override
                public void run() {
                    svnUrl[0] = (String) repositoryPanel.urlComboBox.getEditor().getItem().toString().trim();
                }
            };
            if (SwingUtilities.isEventDispatchThread()) {
                awt.run();
            } else {
                SwingUtilities.invokeAndWait(awt);
            }
            return svnUrl[0].trim();
        } catch (InvocationTargetException e) {
            Subversion.LOG.log(Level.SEVERE, null, e);
        }
        return null;            
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:33,代碼來源:Repository.java

示例11: FiltersComponent

import javax.swing.SwingUtilities; //導入方法依賴的package包/類
/** Not public, instances created using factory method createPanel */
FiltersComponent(FiltersDescription descr) {
    super(BoxLayout.X_AXIS);
    this.filtersDesc = descr;
    // always create swing content in AWT thread
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable () {
            public void run () {
                initPanel();                        
            }
        });
    } else {
        initPanel();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:FiltersManager.java

示例12: tableChanged

import javax.swing.SwingUtilities; //導入方法依賴的package包/類
@Override
public void tableChanged(TableModelEvent e) {
    if (SwingUtilities.isEventDispatchThread()) {
        refreshSQL();
    } else {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                refreshSQL();
            }
        });
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:InsertRecordDialog.java

示例13: changeChildren

import javax.swing.SwingUtilities; //導入方法依賴的package包/類
void changeChildren(final HeapWalkerNode[] children) {
    Runnable childrenChanger = new Runnable() {
        public void run() {
            AbstractHeapWalkerNode.this.children = children;
            indexes = null;
        }
    };
    if (!SwingUtilities.isEventDispatchThread()) {
        try {
            SwingUtilities.invokeAndWait(childrenChanger);
        } catch (Exception ex) {}
    } else {
        childrenChanger.run();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:AbstractHeapWalkerNode.java

示例14: resultChanged

import javax.swing.SwingUtilities; //導入方法依賴的package包/類
@Override
public void resultChanged(LookupEvent ev) {
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(this);
    } else {
        run();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:BraceMatchingSidebarComponent.java

示例15: invokeNowOrLater

import javax.swing.SwingUtilities; //導入方法依賴的package包/類
/**
 * Wrapper for SwingUtilities.invokeLater that handles the case
 * where we are already in the EDT.
 *
 * @param runnable A {@code Runnable} to run.
 */
public void invokeNowOrLater(Runnable runnable) {
    if (SwingUtilities.isEventDispatchThread()) {
        runnable.run();
    } else {
        SwingUtilities.invokeLater(runnable);
    }
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:14,代碼來源:GUI.java


注:本文中的javax.swing.SwingUtilities.isEventDispatchThread方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。