napkin look and feel
i added napkin library and this code
try {
UIManager.setLookAndFeel("net.sourceforge.napkinlaf.Napkin开发者_开发百科LookAndFeel");
} catch (Exception e) {
e.printStackTrace();
}
but i keep getting this exception :
java.lang.ClassNotFoundException: net.sourceforge.napkinlaf.NapkinLookAndFeel
You need to make sure the jar with that class is on your classpath at runtime.
The napkin library is probably not in the classpath of your application, at runtime.
Check what you've specified as the '-cp' argument of your command line, when running the program.
What you mean by 'adding the library' probably means only adding it to the compile-time classpath ; since the name of the class is used, I guess the actual class is loaded dynamically at runtime. So the JVM must have an indication of which jar contains the bytecode for the class.
Are you using Eclipse or some IDE? If so you need to add the dependency/jar file in the build settings. In Eclipse you can just right-click and under Build Path (I believe) select "Add to Build Path".
Otherwise you need to list the dependent jar file when you start Java on the command line. This is one way: java -classpath yourjar.jar;napkinlaf.jar yourpackage.YourMainClass
(You'd have to customize that command line appropriately of course. This is also assuming you're building a jar file for your application...)
Make sure that you download the correct version of the Napkin Look and Feel.
The version currently on the front page of the SourceForge project is unfortunately the alpha001 version which actually has the classes placed in the napkin
package. To use it you need to do the following:
try {
UIManager.setLookAndFeel("napkin.NapkinLookAndFeel");
} catch (Exception e) {
e.printStackTrace();
}
But instead you should go to the "Files" tab in the SourceForge project and browse to find the latest release.
精彩评论