Java eclipse WindowBuilder, change look and feel
Asked Answered
R

5

10

im coding a program using windowbuilder in eclipse. I would like to have help with changing the design (Look and feel) from metal to windows. How would i do that? thank you

Ramillies answered 12/8, 2011 at 20:52 Comment(2)
download.oracle.com/javase/tutorial/uiswing/lookandfeel/…Hipbone
@Hipbone For some reason your link does not show a correct articlePinfish
P
18

In Eclipse go to

Window > Preferences > WindowBuilder > Swing > LookAndFeel

and tick

Apply choosen LookAndFeel in main() method.

This way whenever you change the look and feel in WindowBuilder's design view, it will be applied in the code.

Parcheesi answered 17/10, 2012 at 12:8 Comment(0)
B
5

the Swing call is:

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

i recall in swt the window trims will change naturally when you cycle through the themes since the widgets are actually native to the os. are you using Swing or SWT?

Bollen answered 13/8, 2011 at 1:44 Comment(0)
P
2

That has nothing to with WindowBuilder.

Please read Swing tutorial on Swing Look And Feel at http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

Pinfish answered 13/8, 2011 at 1:31 Comment(1)
Actually, it does, though I don't think the question made it clear enough. The WindowBuilder toolbar has a dropdown that allows you to change look and feel, but it does not actually modify the source like most other toolbar commands do, just the preview. Mohammad's answer above fixes this behavior.Cyclopedia
V
2

I had tried setting WIndow Builder to use the system look and feel in preferences, but it still did not work, but simgineer's solution did. I would add to simgineer's post the specific place to add the code, as well as the tags you should use to hide the code from the Window Builder parser. In you main application 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 ...
        }
    });
}

Cheers

Vieira answered 15/12, 2012 at 14:13 Comment(0)
C
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);
        }
Cookie answered 28/7, 2015 at 12:38 Comment(1)
Welcome to Stackoverflow. Support the answer with few explanation.Zendejas

© 2022 - 2024 — McMap. All rights reserved.