我正在开发一个由某个人作为研究项目的一部分开发的 Java 应用程序。以下是主要方法:
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
// Change the name of the application on a mac
System.setProperty("com.apple.mrj.application.apple.menu.about.name",
"XX");
// Use the top of the screen for the menu on a mac
if( System.getProperty( "mrj.version" ) != null ) {
System.setProperty( "apple.laf.useScreenMenuBar", "true" );
}
try {
// Use system look and feel
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
System.out.println("Cannot use system's look and feel; using Java's default instead");
}
// Create a new instance of XX
XX.getInstance();
}
});
}
现在,我不明白为什么使用事件队列而不是仅仅使用
public static void main(String[] args) {
//the MAC stuff!!
XX.getInstance(); //this line creates the UI and the event handlers
}
使用EventQueue有什么意义吗?