关于Java GUI 和事件处理线程的问题
下面是sun网站上JLayeredPaneDemo的代码片段
我的问题是,为什么要在事件处理线程上调用createAndShowGUI()?
为什么要在事件处理线程上初始化程序?
我的问题是,为什么要在事件处理线程上调用createAndShowGUI()?
为什么要在事件处理线程上初始化程序?
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("LayeredPaneDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
JComponent newContentPane = new LayeredPaneDemo();
newContentPane.setOpaque(true); //content panes must be opaque
frame.setContentPane(newContentPane);
//Display the window.
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
...全文


Java SE
