This article Reprinted from: http://netbeans.csdn.net/page/47c96f7c-a87b-4a98-befc-9e1c0dcafd07
Ubuntu 7.10
Java 6
Netbeans-6.0.1-ml-linux
Use netbeans to create a "Java Desktop Application" (Java Desktop Application). By default, all applications are compiled successfully but cannot run. The following error message (important part) is displayed ):
Couldn't set lookandfeel application. lookandfeel = "system"
Java. Lang. nullpointerexception ....
Exception in thread "AWT-EventQueue-0" Java. Lang. Error: Application class implements topapplication1.topics topapplication1 failed to launch
At org. jdesktop. application. Application $ 1.run( application. Java: 177 )...
The reason is that the Java window program applies the GTK set topic (gtklookandfeel ). By default, the windows program of netbeans 6 applies the environment value of the operating system directly to look and feel. This problem also involves other environments that use Java GUI + GTK. The fastest way to fix this problem is to change the solution.
1) properties-> desktop app-> look & feel value from "System Default"-> "Java default.
2) Project-> properties-> application-> desktop application-> appearance: Change the system default settings to the Java default settings.
However, the program will not be able to apply the subject of the system.
Another better solution is to set the global Font:
Public static void main (string [] ARGs ){
Setuifont (New fontuiresource ("sans", 0, 12 ));
Launch (transportapp. Class, argS );
}
Public static void setuifont (javax. Swing. plaf. fontuiresource f ){
// Setuifont (New javax. Swing. plaf. fontuiresource ("sans", java. AWT. Font. Plain, 9 ));
Enumeration keys = uimanager. getdefaults (). Keys ();
While (Keys. hasmoreelements ()){
Object key = keys. nextelement ();
Object value = uimanager. Get (key );
If (value instanceof fontuiresource ){
Uimanager. Put (Key, F );
}
}
}