做了一些快速的研究后,我找不到任何部分因为我不确定我是否正在寻找正确的东西,部分是因为我认为没有.
但是,请告诉我是否有办法可以浓缩这一点.此外,我是Java的新手,如果你能用简单的术语解释你的变化及其作用,那也很棒!
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager
.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(GameOfLife.class.getName()).log(
java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(GameOfLife.class.getName()).log(
java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(GameOfLife.class.getName()).log(
java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(GameOfLife.class.getName()).log(
java.util.logging.Level.SEVERE, null, ex);
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new GameOfLife().setVisible(true);
}
});
Run Code Online (Sandbox Code Playgroud)
hin*_*nks 11
您可以使用Multi-Catch(最小JDK 7):只需使用|
符号分隔Exception-Classes
try {
someMethod();
} catch (IOException | SQLException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
154 次 |
最近记录: |