[问题]关于Java Desktop Application(用netbeans IDE 6.0 Beta 1)

C、C++和Java语言
回复
wwwangee
帖子: 18
注册时间: 2007-08-11 13:56
送出感谢: 0
接收感谢: 0
联系:

[问题]关于Java Desktop Application(用netbeans IDE 6.0 Beta 1)

#1

帖子 wwwangee » 2007-11-29 22:31

我下载的是netbeans-6.0beta1-javase-linux.sh,然后运行sh netbeans-6.0beta1-javase-linux.sh,显示如下

代码: 全选

Configuring the installer...
Searching for JVM on the system...
Extracting installation data...
Running the installer wizard...

(<unknown>:17320): Gtk-WARNING **: Attempting to add a widget with type GtkButton to a GtkComboBoxEntry (need an instance of GtkEntry or of a subclass)

(<unknown>:17320): Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed

(<unknown>:17320): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed

(<unknown>:17320): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed

(<unknown>:17320): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed

(<unknown>:17320): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed

(<unknown>:17320): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed

(<unknown>:17320): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed


然后我用netbeans新建一个Java Desktop Application,全部默认,编译成功,但是无法运行,显示如下:

代码: 全选

run:
2007-11-29 14:17:56 org.jdesktop.application.Application create
警告: Couldn't set LookandFeel Application.lookAndFeel = "system"
java.lang.NullPointerException
        at javax.swing.plaf.synth.SynthLookAndFeel$AATextListener.propertyChange(SynthLookAndFeel.java:793)
        at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
        at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:347)
        at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
        at java.awt.Toolkit.setDesktopProperty(Toolkit.java:1784)
        at sun.awt.SunToolkit.fireDesktopFontPropertyChanges(SunToolkit.java:1698)
        at sun.awt.SunToolkit.setAAFontSettingsCondition(SunToolkit.java:1743)
        at sun.swing.SwingUtilities2$AATextInfo.getAATextInfo(SwingUtilities2.java:119)
        at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.initComponentDefaults(GTKLookAndFeel.java:1258)
        at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.getDefaults(GTKLookAndFeel.java:294)
        at javax.swing.UIManager.setLookAndFeel(UIManager.java:537)
        at javax.swing.UIManager.setLookAndFeel(UIManager.java:581)
        at org.jdesktop.application.Application.create(Application.java:249)
        at org.jdesktop.application.Application$1.run(Application.java:172)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
2007-11-29 14:17:56 org.jdesktop.application.Application$1 run
严重: Application class desktopapplication1.DesktopApplication1 failed to launch
java.lang.NullPointerException
        at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:117)
        at javax.swing.UIDefaults.getUI(UIDefaults.java:741)
        at javax.swing.UIManager.getUI(UIManager.java:1012)
        at javax.swing.JPanel.updateUI(JPanel.java:109)
        at javax.swing.JPanel.<init>(JPanel.java:69)
        at javax.swing.JPanel.<init>(JPanel.java:92)
        at javax.swing.JPanel.<init>(JPanel.java:100)
        at desktopapplication1.DesktopApplication1View.initComponents(DesktopApplication1View.java:102)
        at desktopapplication1.DesktopApplication1View.<init>(DesktopApplication1View.java:27)
        at desktopapplication1.DesktopApplication1.startup(DesktopApplication1.java:19)
        at org.jdesktop.application.Application$1.run(Application.java:174)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Exception in thread "AWT-EventQueue-0" java.lang.Error: Application class desktopapplication1.DesktopApplication1 failed to launch
        at org.jdesktop.application.Application$1.run(Application.java:180)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: java.lang.NullPointerException
        at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:117)
        at javax.swing.UIDefaults.getUI(UIDefaults.java:741)
        at javax.swing.UIManager.getUI(UIManager.java:1012)
        at javax.swing.JPanel.updateUI(JPanel.java:109)
        at javax.swing.JPanel.<init>(JPanel.java:69)
        at javax.swing.JPanel.<init>(JPanel.java:92)
        at javax.swing.JPanel.<init>(JPanel.java:100)
        at desktopapplication1.DesktopApplication1View.initComponents(DesktopApplication1View.java:102)
        at desktopapplication1.DesktopApplication1View.<init>(DesktopApplication1View.java:27)
        at desktopapplication1.DesktopApplication1.startup(DesktopApplication1.java:19)
        at org.jdesktop.application.Application$1.run(Application.java:174)
        ... 8 more
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.initSystemColorDefaults(GTKLookAndFeel.java:1267)
        at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.loadStyles(GTKLookAndFeel.java:1509)
        at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.access$000(GTKLookAndFeel.java:37)
        at com.sun.java.swing.plaf.gtk.GTKLookAndFeel$WeakPCL$1.run(GTKLookAndFeel.java:1449)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.initSystemColorDefaults(GTKLookAndFeel.java:1267)
        at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.loadStyles(GTKLookAndFeel.java:1509)
        at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.access$000(GTKLookAndFeel.java:37)
        at com.sun.java.swing.plaf.gtk.GTKLookAndFeel$WeakPCL$1.run(GTKLookAndFeel.java:1449)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
BUILD SUCCESSFUL (total time: 2 seconds)

不知道是哪里出了问题,所以我也把安装时出的错贴出来了,请大家看看怎么解决,先谢谢了!
头像
stlxv
论坛版主
帖子: 8273
注册时间: 2006-05-03 0:39
来自: المريخ
送出感谢: 0
接收感谢: 1 次

#2

帖子 stlxv » 2007-11-29 23:23

你换一个look and feel试试
PHP是最好的语言!不服来战!
头像
titainium
帖子: 689
注册时间: 2006-12-02 12:25
送出感谢: 0
接收感谢: 0

#3

帖子 titainium » 2007-12-13 22:13

安装源里面的版本。
Titainium
chirst
帖子: 8
注册时间: 2007-11-07 14:25
送出感谢: 0
接收感谢: 0
联系:

基本解决了

#4

帖子 chirst » 2007-12-15 20:53

可以将resources中的.properties文件中
Application.lookAndfeel=system中system随便改成什么,只要不为空
头像
titainium
帖子: 689
注册时间: 2006-12-02 12:25
送出感谢: 0
接收感谢: 0

#5

帖子 titainium » 2007-12-18 18:27

可以将resources中的.properties文件中
Application.lookAndfeel=system中system随便改成什么,只要不为空


这个方法只是让程序可以run,但是还会有错误信息产生,正在找其他的办法,原来装了源里面的版本还是一样会。 :em06
Titainium
wwwangee
帖子: 18
注册时间: 2007-08-11 13:56
送出感谢: 0
接收感谢: 0
联系:

#6

帖子 wwwangee » 2007-12-22 23:47

如果换个jdk是不是就行了?我改天试试!
wwwangee
帖子: 18
注册时间: 2007-08-11 13:56
送出感谢: 0
接收感谢: 0
联系:

#7

帖子 wwwangee » 2007-12-22 23:51

其实不是Java Desktop Application的问题,
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
如果放在界面启动前就会出错
头像
titainium
帖子: 689
注册时间: 2006-12-02 12:25
送出感谢: 0
接收感谢: 0

#8

帖子 titainium » 2007-12-24 20:54

你要将这句:
可以将resources中的.properties文件中
Application.lookAndfeel=system
改掉,改成系统自带的lookandfeel,我用的是javax.swing.plaf.metal.metallookandfeel,你在import的时候可以选一下,这样就不会报错了。
Titainium
wwwangee
帖子: 18
注册时间: 2007-08-11 13:56
送出感谢: 0
接收感谢: 0
联系:

谢谢

#9

帖子 wwwangee » 2007-12-26 17:45

javax.swing.plaf.metal.MetalLookAndFeel和com.sun.java.swing.plaf.motif.MotifLookAndFeel都不出错,
但是 com.sun.java.swing.plaf.gtk.GTKLookAndFeel就 会出错。
头像
titainium
帖子: 689
注册时间: 2006-12-02 12:25
送出感谢: 0
接收感谢: 0

#10

帖子 titainium » 2007-12-28 22:15

com.sun.java.swing.plaf.gtk.GTKLookAndFeel应该没有默认安装,所以才报错。
Titainium
头像
qingshi163
帖子: 275
注册时间: 2007-12-16 0:45
送出感谢: 0
接收感谢: 0
联系:

#11

帖子 qingshi163 » 2008-02-14 9:36

我今天又试了一下,已经可以在GTK下运行了。
我的系统配置:
ubuntu7.10
netbeans-6.0.1-ml-javase-linux.sh(原来的6.0怎么都不行。不过这个版本依然有错误提示,没有关系,什么都不影响。)
jdk-6u10-ea-bin-b11-linux-amd64-24-jan-2008.bin(其他的我不知道.)
这时候如果你直接用正常的UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())(等于直接用GTKLookAndFeel)还是会跳出一连串的错误。不过我偶然发现,如果你在它的前面加上全局字体控制,就可以运行了。

全局字体控制的代码:

代码: 全选

public static void setUIFont(javax.swing.plaf.FontUIResource f) {
        // setUIFont (new javax.swing.plaf.FontUIResource("Serif",Font.ITALIC,12));
        java.util.Enumeration keys = UIManager.getDefaults().keys();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);
            if (value instanceof javax.swing.plaf.FontUIResource) {
                UIManager.put(key, f);
            }
        }
}


最终代码象这样:

代码: 全选

public static void main(String args[]) {
        [color=red]setUIFont(new javax.swing.plaf.FontUIResource("微软雅黑", 0, 13));[/color]
        //先加上这句就可以运行了
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Goaide.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(Goaide.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Goaide.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(Goaide.class.getName()).log(Level.SEVERE, null, ex);
        }
       
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new /*主窗口名*/().setVisible(true);
            }
        });
    }
   
    public static void setUIFont(javax.swing.plaf.FontUIResource f) {
        /* setUIFont (new javax.swing.plaf.FontUIResource("Serif",Font.ITALIC,12));
         *   设置方法
        */
        java.util.Enumeration keys = UIManager.getDefaults().keys();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);
            if (value instanceof javax.swing.plaf.FontUIResource) {
                UIManager.put(key, f);
            }
        }
    }


不过这样虽然可以运行,不过还是会出来一些错误(和netbeans一样的错误,它是不是这样解决的呢?wink:不过倒是不影响运行的。),要是谁解决了,一定要告诉我一声呀!

出现的错误:
(<unknown>:6066): Gtk-WARNING **: Attempting to add a widget with type GtkButton to a GtkComboBoxEntry (need an instance of GtkEntry or of a subclass)

(<unknown>:6066): Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed

(<unknown>:6066): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed

(<unknown>:6066): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed :
头像
goingt
帖子: 6
注册时间: 2008-03-08 9:49
来自: 福建厦门
送出感谢: 0
接收感谢: 0
联系:

#12

帖子 goingt » 2008-03-08 9:51

转贴自:http://hi.baidu.com/issaria/blog/item/52e4f80fa65250e9ab64579d.html


如果采用GNOME的LINUX(如Ubuntu)和NetBeans 6开发窗口化程序会存在一些小问题。运行时抛出如下异常(重点部分):

Couldn't set LookandFeel Application.lookAndFeel = "system"
java.lang.NullPointerException ....

Exception in thread "AWT-EventQueue-0" java.lang.Error: Application class desktopapplication1.DesktopApplication1 failed to launch
at org.jdesktop.application.Application$1.run(Application.java:177) ...

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.sunjava.swing.plaf.gtk.GTKLookAndFeel.initSystemColorDefaults(GTKLookAndFeel.java:1267)
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.loadStyles(GTKLookAndFeel.java:1509)

原因在于java窗口程序套用GTK布景主题(GTKLookAndFeel)。Netbeans 6 的 窗口化程序的默认情况下 Look and Feel 会直接套用操作系统的环境值。
最快修复这个问题的办法是更改该方案Properties -> Desktop App -> Look & Feel值从"System Default" -> "Java Default" 即可。这个问题也会同时存在其他使用Java GUI + GTK 的环境。
wan_2004
帖子: 41
注册时间: 2007-06-02 17:20
送出感谢: 0
接收感谢: 0

#13

帖子 wan_2004 » 2008-03-12 22:06

11楼正解 谢谢
要用GTK必须这样
不过我的没有报其它错
呵呵
fivemight
帖子: 1
注册时间: 2008-07-21 14:41
送出感谢: 0
接收感谢: 0

[已解决]最新版的JRE已经解决了这个问题

#14

帖子 fivemight » 2008-07-21 14:48

最新版的JRE已经解决了这个问题。
还有个瑕疵就是WTK没有64位版本,如果在64位版本上使用32位的JRE来运行WTK,使用系统外观的话会报输入法的连接库对不上的警告(它想找32位的so,可是机器上只有64位的so),不过不影响运行,输入法也能用。
回复

回到 “C/C++/Java”