[英]Java eclipse WindowBuilder, change look and feel
我在 eclipse 中使用 windowbuilder 編寫程序。 我想幫助將設計(外觀和感覺)從金屬更改為 windows。 我該怎么做? 謝謝你
在 Eclipse go 到
Window > 首選項 > WindowBuilder > Swing > LookAndFeel
並打勾
在 main() 方法中應用選擇的 LookAndFeel 。
這樣,每當您在 WindowBuilder 的設計視圖中更改外觀和感覺時,它都會應用到代碼中。
Swing 調用是:
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception e) {
System.out.println("Error setting native LAF: " + e);
}
我記得在 swt 中,當您循環瀏覽主題時,window 裝飾會自然變化,因為這些小部件實際上是操作系統的原生組件。 您使用的是 Swing 還是 SWT?
我曾嘗試設置 WIndow Builder 以在首選項中使用系統外觀,但它仍然不起作用,但 simgineer 的解決方案可以。 我會在 simgineer 的帖子中添加添加代碼的特定位置,以及您應該使用哪些標簽來隱藏 Window Builder 解析器中的代碼。 在您的主要應用程序 window...
public static void main(String[] args) {
// hide>>$
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception e) {
System.out.println("Error setting native LAF: " + e);
}
// $hide<<$
EventQueue.invokeLater(new Runnable() {
public void run() {
// generated code ...
}
});
}
干杯
這與 WindowBuilder 無關。
Please read Swing tutorial on Swing Look And Feel at http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Windows".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(BiatApp.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(BiatApp.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(BiatApp.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(BiatApp.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.