Joh*_*iou 2 java user-interface netbeans look-and-feel
使用Java中的Mac上的Netbeans GUI构建器构建.
这就是Netbeans中GUI的样子:

当我点击预览时,它看起来并不太糟糕,但有一些小变化:

最后,当我运行它时,它看起来像这样: - 太可怕了

我认为这与Java的"外观和感觉"有关.我试过删除它,GUI变得一团糟.那么我的选择是什么?正如你可以看到Netbeans中的所有内容一样,当我运行它时,一切都很糟糕.
有任何想法吗?花了一天时间搞乱了这一点,我至少可以说
在你编码的某些地方,Netbeans会创建一个main方法(这将在Netbeans执行的类中,并且可能是你的主框架 - 我认为这将是SPPMainGUI)
它看起来像这样(注意它可能是"折叠"所以你只会看到第一个注释和decs第二个注释(Look and feel setting code (optional)))
/* 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 {
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(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
Run Code Online (Sandbox Code Playgroud)
通过点击在边缘的小+展开代码块,更换for-loop有UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());如下
/* 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 {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
Run Code Online (Sandbox Code Playgroud)
当afsantos发现问题时,如果你能接受他的答案是正确的(并且反而投票给我),我会赞美它,轻推,轻推,眨眼,眨眼,不再说了)
| 归档时间: |
|
| 查看次数: |
2295 次 |
| 最近记录: |