当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 14 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : [问题]关于Java Desktop Application(用netbeans IDE 6.0 Beta 1)
帖子发表于 : 2007-11-29 22:31 

注册: 2007-08-11 13:56
帖子: 18
送出感谢: 0 次
接收感谢: 0 次
我下载的是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)

不知道是哪里出了问题,所以我也把安装时出的错贴出来了,请大家看看怎么解决,先谢谢了!


页首
 用户资料  
 
2 楼 
 文章标题 :
帖子发表于 : 2007-11-29 23:23 
头像

注册: 2006-05-03 0:39
帖子: 8273
地址: المريخ
送出感谢: 0 次
接收感谢: 1
你换一个look and feel试试


_________________
PHP是最好的语言!不服来战!


页首
 用户资料  
 
3 楼 
 文章标题 :
帖子发表于 : 2007-12-13 22:13 
头像

注册: 2006-12-02 12:25
帖子: 689
送出感谢: 0 次
接收感谢: 0 次
安装源里面的版本。


_________________
Titainium


页首
 用户资料  
 
4 楼 
 文章标题 : 基本解决了
帖子发表于 : 2007-12-15 20:53 

注册: 2007-11-07 14:25
帖子: 8
送出感谢: 0 次
接收感谢: 0 次
可以将resources中的.properties文件中
Application.lookAndfeel=system中system随便改成什么,只要不为空


页首
 用户资料  
 
5 楼 
 文章标题 :
帖子发表于 : 2007-12-18 18:27 
头像

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


这个方法只是让程序可以run,但是还会有错误信息产生,正在找其他的办法,原来装了源里面的版本还是一样会。 :em06


_________________
Titainium


页首
 用户资料  
 
6 楼 
 文章标题 :
帖子发表于 : 2007-12-22 23:47 

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


页首
 用户资料  
 
7 楼 
 文章标题 :
帖子发表于 : 2007-12-22 23:51 

注册: 2007-08-11 13:56
帖子: 18
送出感谢: 0 次
接收感谢: 0 次
其实不是Java Desktop Application的问题,
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
如果放在界面启动前就会出错


页首
 用户资料  
 
8 楼 
 文章标题 :
帖子发表于 : 2007-12-24 20:54 
头像

注册: 2006-12-02 12:25
帖子: 689
送出感谢: 0 次
接收感谢: 0 次
你要将这句:
可以将resources中的.properties文件中
Application.lookAndfeel=system
改掉,改成系统自带的lookandfeel,我用的是javax.swing.plaf.metal.metallookandfeel,你在import的时候可以选一下,这样就不会报错了。


_________________
Titainium


页首
 用户资料  
 
9 楼 
 文章标题 : 谢谢
帖子发表于 : 2007-12-26 17:45 

注册: 2007-08-11 13:56
帖子: 18
送出感谢: 0 次
接收感谢: 0 次
javax.swing.plaf.metal.MetalLookAndFeel和com.sun.java.swing.plaf.motif.MotifLookAndFeel都不出错,
但是 com.sun.java.swing.plaf.gtk.GTKLookAndFeel就 会出错。


页首
 用户资料  
 
10 楼 
 文章标题 :
帖子发表于 : 2007-12-28 22:15 
头像

注册: 2006-12-02 12:25
帖子: 689
送出感谢: 0 次
接收感谢: 0 次
com.sun.java.swing.plaf.gtk.GTKLookAndFeel应该没有默认安装,所以才报错。


_________________
Titainium


页首
 用户资料  
 
11 楼 
 文章标题 :
帖子发表于 : 2008-02-14 9:36 
头像

注册: 2007-12-16 0:45
帖子: 275
送出感谢: 0 次
接收感谢: 0 次
我今天又试了一下,已经可以在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 :


页首
 用户资料  
 
12 楼 
 文章标题 :
帖子发表于 : 2008-03-08 9:51 
头像

注册: 2008-03-08 9:49
帖子: 6
地址: 福建厦门
送出感谢: 0 次
接收感谢: 0 次
转贴自: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 的环境。


页首
 用户资料  
 
13 楼 
 文章标题 :
帖子发表于 : 2008-03-12 22:06 

注册: 2007-06-02 17:20
帖子: 41
送出感谢: 0 次
接收感谢: 0 次
11楼正解 谢谢
要用GTK必须这样
不过我的没有报其它错
呵呵


页首
 用户资料  
 
14 楼 
 文章标题 : [已解决]最新版的JRE已经解决了这个问题
帖子发表于 : 2008-07-21 14:48 

注册: 2008-07-21 14:41
帖子: 1
送出感谢: 0 次
接收感谢: 0 次
最新版的JRE已经解决了这个问题。
还有个瑕疵就是WTK没有64位版本,如果在64位版本上使用32位的JRE来运行WTK,使用系统外观的话会报输入法的连接库对不上的警告(它想找32位的so,可是机器上只有64位的so),不过不影响运行,输入法也能用。


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 14 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 3 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译