当前位置: 首页>>代码示例>>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;未经允许,请勿转载。