Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Applet In Web Page Does Not Respect Set Look And Feel
    primarykey
    data
    text
    <p>I am trying to set the look and feel (LAF) of a Java applet that is used via a web browser. I wish to set the system default LAF, but when loaded in a browser, the applet returns to the Metal LAF. When I run it as a stand-alone applet, the LAF is applied correctly. The only item I am showing the user is a JFileChooser. I have tried a number of methods to overcome this including:</p> <h2>1) Override the applet's start() method:</h2> <pre><code>@Override public void start() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); SwingUtilities.updateComponentTreeUI(this); System.out.println("LOOK AND FEEL SET!"); } catch (Exception ex) { System.out.println(ex); } } </code></pre> <h2>2) Set it in the static initializer of the applet class:</h2> <pre><code>static { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); System.out.println("LOOK AND FEEL SET!"); } catch (Exception ex) { System.out.println(ex); } } </code></pre> <h2>3) Set it in the constructor of the applet:</h2> <pre><code>public MyApplet() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); SwingUtilities.updateComponentTreeUI(this); System.out.println("LOOK AND FEEL SET!"); } catch (Exception ex) { System.out.println(ex); } } </code></pre> <p>I am using Java 6, but targeting Java 5 on Windows. In every case, <em>LOOK AND FEEL SET!</em> gets printed to the console, so I know that it set it without throwing an exception. This happens irrespective of browser (using Firefox 3.6 and IE7). <strong>Why is it doing this and how can I get it to respect the LAF I designate?</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload