Cha*_*min 5 java swing swingworker swingutilities
启动java swing应用程序的最佳实践方法是什么?也许有另一种方法可以做到这一点.
我想知道我是否必须使用SwingUtilities类来启动应用程序(可能性)(第一种可能性).
public class MyFrame extends JFrame {
public void createAndShowGUI() {
this.setSize(300, 300);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
// add components and stuff
this.setVisible(true);
}
public static void main(String[] args) {
// First possibility
MyFrame mf = new MyFrame();
mf.createAndShowGUI();
// Secound possibility
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
MyFrame mf = new MyFrame();
mf.createAndShowGUI();
}
});
}
Run Code Online (Sandbox Code Playgroud)
}