Problem with Java FX Look and Feel

Posted by drachenfels on Stack Overflow See other posts from Stack Overflow or by drachenfels
Published on 2010-05-14T20:27:38Z Indexed on 2010/05/14 20:54 UTC
Read the original article Hit count: 152

Filed under:
|
|

Hi,

I was looking at some of the examples from the Deitel and Deitel's book for Programming in Java, and one of the first examples is a very simple Swing display. Hence this snippet of code :

   import javax.swing.*; 

    public class cdea {     

public static void main(String args[]){
                    JOptionPane.showMessageDialog(null,"\"Welcome to Java Programming!\"");
                    System.exit(0);

          //end method main
    }
    }

I read some stuff regarding how one can get native UI look and feel by using

UIManager.setLookAndFeel(
            UIManager.getSystemLookAndFeelClassName());

to the program. However, when I just add this to my main method, it gives me a host of errors. Specifically :

Multiple markers at this line - Unhandled exception type IllegalAccessException - Unhandled exception type InstantiationException - Unhandled exception type ClassNotFoundException - Unhandled exception type UnsupportedLookAndFeelException

However when I use it as part of a try/catch exception loop (is that what it is called?) as detailed on http://stackoverflow.com/questions/1590863/getting-java-applications-to-look-native-on-windows-how , I get the program running properly.

Could anyone tell me in simple language why this is so? As in, why can't I directly get the System look and feel; why do I have to use it with exception handling? I'm new to Java, and OOP in general, so I'm sorry if I'm being too simplistic.

© Stack Overflow or respective owner

Related posts about java

Related posts about swing