当我在 Netbeans 中创建一个新的 JFrame 时,会自动创建一个主类。即使我把它放在/* */
代码中也可以正常工作。我在任何 Java 程序中了解到,必须只有一个主类是程序的起点。
- JFrame中的主类有什么用?
- 如果我保留或删除它有什么问题吗?
- 我什么时候可以调用主类中的代码?
// public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
/* try {
System.out.println("111111111111111");
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Welcome.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/*
/* Create and display the form
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
//welcomeUser.setText("Welcome");
System.out.println("111111111111111");
//new Welcome().setVisible(true);
System.out.println("333333333333333");
}
});*/
// }