Home arrow static arrow Java Programming [Archive] - Can't change "look and feel" in Applet
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Can't change "look and feel" in Applet
This topic has 3 replies on 1 page.

Posts:26
Registered: 6/6/04
Can't change "look and feel" in Applet  
Jul 23, 2004 3:00 AM



 
Hi everybody,

I'm trying to change the look and feel in my applet from init() method but

calling " System.out.println(UIManager.getSystemLookAndFeelClassName());" gives me always

the standard windows look and feel .

I want to use 2 different LAF's (installed by the 2 following methods) and I do like this :

public void init() {         setSmoothMetalLookAndFeel();//or  setMotifLookAndFeel();        System.out.println(UIManager.getSystemLookAndFeelClassName());         try {            jbInit();        } catch (Exception e) {            e.printStackTrace();        }    }     public static void setSmoothMetalLookAndFeel() {        try {             UIManager.setLookAndFeel("smooth.windows.SmoothLookAndFeel");        } catch (Exception e) {            System.out.println("Error setting native LAF: " + e);        }    }    public static void setMotifLookAndFeel() {        try {            UIManager.setLookAndFeel(                    "com.sun.java.swing.plaf.motif.MotifLookAndFeel");        } catch (Exception e) {            System.out.println("Error setting Motif LAF: " + e);        }    }


What am i doing wrong?
Thank you very much

Chris
 

Posts:65
Registered: 7/28/99
Re: Can't change "look and feel" in Applet  
Jul 23, 2004 3:19 AM (reply 1 of 3)



 
calling System.out.println(UIManager.getSystemLookAndFeelClassName()) gives you
the name for the default LAF for your operating system.
This is NOT the acutal set LAF. see docu

Herby
 

Posts:26
Registered: 6/6/04
Re: Can't change "look and feel" in Applet  
Jul 23, 2004 4:17 AM (reply 2 of 3)



 
Ok you're right.
But the problem remains the same:I try to change the look and feel and its not what supposed to be.

Whatever LAF i choose ,running my applet from JBuilder (not from the html file ),graphics look the same.
 

Posts:65
Registered: 7/28/99
Re: Can't change "look and feel" in Applet  
Jul 23, 2004 6:45 AM (reply 3 of 3)



 
Wher do you instantiate your components?

Does Jbuilder create code where the components are created like

private JButton iButton= new JButton("Texte"); ?

In this case the component UI is created befor the LAF is set.
Instantiate the components in init() AFTER the LAF is set.

Herbert

 
This topic has 3 replies on 1 page.