Solution to netbeans6 development exceptions in GNOME/GTK

Source: Internet
Author: User
Tags gtk netbeans

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 );
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.