Java eclipse WindowBuilder,改变外观和感觉

时间:2011-08-12 20:52:23

标签: java eclipse look-and-feel windowbuilder

我在eclipse中使用windowbuilder编写程序。我想帮助改变从金属到窗户的设计(外观和感觉)。我该怎么做?谢谢

5 个答案:

答案 0 :(得分:18)

在Eclipse中转到

窗口>偏好> WindowBuilder> Swing>的LookAndFeel

并勾选

在main()方法中应用选择的LookAndFeel

这样,无论何时在WindowBuilder的设计视图中更改外观,它都将应用于代码中。

答案 1 :(得分:3)

Swing调用是:

try {
  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception e) {
  System.out.println("Error setting native LAF: " + e);
}

我记得在swt中,当你循环浏览主题时,窗口修剪会自然地改变,因为小部件实际上是os的原生。你使用Swing还是SWT?

答案 2 :(得分:2)

与WindowBuilder无关。

请阅读http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

上的Swing Look And Feel的Swing教程

答案 3 :(得分:2)

我曾尝试过设置WIndow Builder以在偏好中使用系统外观,但它仍然无效,但是simgineer的解决方案确实如此。我会在simgineer的帖子中添加添加代码的特定位置,以及用于隐藏Window Builder解析器代码的标签。在您的主应用程序窗口中......

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 ...
        }
    });
}

干杯

答案 4 :(得分:0)

 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);
        }