954,554 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

look and feel

I'm in need of determining and implementing the LookAndFeel of the operating system default within a swing frame, whatever that default may happen to be (and without using the string "com.sun.java.swing.plaf..." in the code whatsoever. When simply leaving the UIManager.setLookAndFeel() as is when creating the frame, the correct OS default doesent show up. I'm assuming that Java swing components like to have a LookAndFeel that is java default, not operating system default...

nanosani
Unauthenticated Liar
Team Colleague
1,830 posts since Jul 2004
Reputation Points: 45
Solved Threads: 56
 

Atlast I figured it out

"UIManager.getSystemLookAndFeelClassName()" will return the name of the default system look and feel... From there just do UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); and you're all set!

nanosani
Unauthenticated Liar
Team Colleague
1,830 posts since Jul 2004
Reputation Points: 45
Solved Threads: 56
 

Could you show a sample of this..I am building a menu of sorts and tried this but when compiled I recieved an exception error stating the classname has to be caught from the system to be thrown..


PanelDemo.java [71:1] unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
^

ZEEPLE
Newbie Poster
15 posts since Aug 2004
Reputation Points: 10
Solved Threads: 0
 
PanelDemo.java [71:1] unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); ^

use the try catch blocks ....

try{
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(ClassNotFoundExecption e){
System.out.println("class not found");
}


Let me know if it works.

nanosani
Unauthenticated Liar
Team Colleague
1,830 posts since Jul 2004
Reputation Points: 45
Solved Threads: 56
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You