1

我所有的示例程序都创建了一个JFrame包含其组件所有代码的 big,而不是为组件创建单独的类,然后将这些组件添加到 big JFrame. 这个 bigJFrame是通过在匿名内部实例化来运行或显示的Runnable,如下所示。

public static void main(String args[]) {  
    // Create the frame on the event dispatching thread.  
    SwingUtilities.invokeLater(new Runnable() {  
        public void run() {  
            new StopWatch();  // Or any other JFrame
        }  
    });  
}

StopWatch实现ActionListener。如果我将其作为类StopWatch实现ActionListenerRunnable然后将其作为可运行对象传递给invokeLater方法,会有什么不同吗?有没有其他方法可以做上面的代码?

4

0 回答 0