本文整理汇总了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();
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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);
}
});
}
}
示例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);
}
});
}
}
示例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);
}
});
}
}
示例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);
}
});
}
}
示例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();
}
});
}
}
}
示例9: setupComponents
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void setupComponents() {
if (SwingUtilities.isEventDispatchThread()) {
setupComponentsNow();
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
setupComponentsNow();
}
});
}
}
示例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;
}
}
示例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();
}
}
示例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();
}
});
}
}
示例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();
}
}
示例14: resultChanged
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Override
public void resultChanged(LookupEvent ev) {
if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater(this);
} else {
run();
}
}
示例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);
}
}