我该怎么找错误啊。什么原因可能导致不报异常位置。
哪位仁兄帮帮忙,都困扰我好几天了。
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.plaf.basic.BasicTreeUI.paint(BasicTreeUI.java:1140)
at javax.swing.plaf.metal.MetalTreeUI.paint(MetalTreeUI.java:152)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:143)
at javax.swing.JComponent.paintComponent(JComponent.java:763)
at javax.swing.JComponent.paint(JComponent.java:1027)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5122)
at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:285)
at javax.swing.RepaintManager.paint(RepaintManager.java:1128)
at javax.swing.JComponent._paintImmediately(JComponent.java:5070)
at javax.swing.JComponent.paintImmediately(JComponent.java:4880)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:723)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:679)
at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:659)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)
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)
18 个解决方案
#1
怎么会不报异常位置呢?
难道……
难道……
#2
空指针异常,看看那个对象没有被初始化,如果用Netbeans或Eclipse根据输出提示找错误所在行
#3
#4
人家都说了没报错误所在行。
你自己看嘛
反正我没看的到。
#5
括号里都可以点进去啊 基本是在paint方法中碰到的空指针 再看看吧
#6
java.lang.NullPointerException
为空指针,Exception
看下你new 没有呀,
没有出错的位置 ,就跟到程序走一次,
每一个地方都System.out.println()下,
慢慢来,总找的出来的,
为空指针,Exception
看下你new 没有呀,
没有出错的位置 ,就跟到程序走一次,
每一个地方都System.out.println()下,
慢慢来,总找的出来的,
#7
估计楼主没解决呢
我也碰到啦。。也是cs的程序连接数据库
最开始报
[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
我发现是那个数据库服务器的防火墙关啦后再连就报这个
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
还没解决正在找答案!
我也碰到啦。。也是cs的程序连接数据库
最开始报
[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
我发现是那个数据库服务器的防火墙关啦后再连就报这个
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
还没解决正在找答案!
#8
#9
LZ是不是调用了updateUI()来刷新啊,
#10
我也遇到了同样的问题啊, 不知楼主是怎样解决的 , 能告知与否?
#11
是因为显示调用updateUI()的原因
#12
我也遇到此问题 谁人解答
#13
也遇到同样问题,自己一直在查,
等待高手解决
等待高手解决
#14
发生了同样的问题,查到这篇老帖,看回复中有童鞋提到调用了updateUI导致,经检查确实如此,但是不调用又不行,会导致树叶的内容显示出现省略号,由于加载树叶启用了新线程,联想到swing的多线程机制,随后将updateUI()放入到 SwingUtilities.invokeLater()中进行,问题解决。
#15
StudentObjectStream obs=new StudentObjectStream();
List lst1=new ArrayList();
File f= new File(System.getProperty("user.dir")+"\\"+"student.obj");
if (f.exists())//当文件存在时,要先从文件中读出记录,再增加记录。
lst1=(List)obs.read1(System.getProperty("user.dir")+"\\"+"student.obj");
System.out.println(lst1.size());
Student s1=new Student(jComboBox1.getSelectedItem().toString(),jTextField1.getText(),jTextField2.getText(),jComboBox2.getSelectedItem().toString(),Integer.parseInt(jTextField3.getText()));
lst1.add(s1);
jComboBox1.setSelectedItem("计应");
jComboBox2.setSelectedItem("英语");
jTextField1.setText(null);
jTextField2.setText(null);
jTextField3.setText(null);
obs.write1(System.getProperty("user.dir")+"\\"+"student.obj", lst1);
请帮我看看这段代码哪错了。我的错误跟楼主一样
List lst1=new ArrayList();
File f= new File(System.getProperty("user.dir")+"\\"+"student.obj");
if (f.exists())//当文件存在时,要先从文件中读出记录,再增加记录。
lst1=(List)obs.read1(System.getProperty("user.dir")+"\\"+"student.obj");
System.out.println(lst1.size());
Student s1=new Student(jComboBox1.getSelectedItem().toString(),jTextField1.getText(),jTextField2.getText(),jComboBox2.getSelectedItem().toString(),Integer.parseInt(jTextField3.getText()));
lst1.add(s1);
jComboBox1.setSelectedItem("计应");
jComboBox2.setSelectedItem("英语");
jTextField1.setText(null);
jTextField2.setText(null);
jTextField3.setText(null);
obs.write1(System.getProperty("user.dir")+"\\"+"student.obj", lst1);
请帮我看看这段代码哪错了。我的错误跟楼主一样
#16
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(Unknown Source)
at javax.swing.plaf.basic.BasicTextAreaUI.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at javax.swing.JTextArea.getPreferredSize(Unknown Source)
at javax.swing.ScrollPaneLayout.layoutContainer(Unknown Source)
at java.awt.Container.layout(Unknown Source)
at java.awt.Container.doLayout(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validate(Unknown Source)
at javax.swing.RepaintManager.validateInvalidComponents(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
这就没有哪一行啊··
at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(Unknown Source)
at javax.swing.plaf.basic.BasicTextAreaUI.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at javax.swing.JTextArea.getPreferredSize(Unknown Source)
at javax.swing.ScrollPaneLayout.layoutContainer(Unknown Source)
at java.awt.Container.layout(Unknown Source)
at java.awt.Container.doLayout(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validate(Unknown Source)
at javax.swing.RepaintManager.validateInvalidComponents(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
这就没有哪一行啊··
#17
估计是你定义的表名与默认关键字是一样的!例如你的表名为“user”,而user是关键字,所以会出现这样的异常。。。
#18
初来乍论坛,还望大家多多关照,多多指教。
#1
怎么会不报异常位置呢?
难道……
难道……
#2
空指针异常,看看那个对象没有被初始化,如果用Netbeans或Eclipse根据输出提示找错误所在行
#3
#4
人家都说了没报错误所在行。
你自己看嘛
反正我没看的到。
#5
括号里都可以点进去啊 基本是在paint方法中碰到的空指针 再看看吧
#6
java.lang.NullPointerException
为空指针,Exception
看下你new 没有呀,
没有出错的位置 ,就跟到程序走一次,
每一个地方都System.out.println()下,
慢慢来,总找的出来的,
为空指针,Exception
看下你new 没有呀,
没有出错的位置 ,就跟到程序走一次,
每一个地方都System.out.println()下,
慢慢来,总找的出来的,
#7
估计楼主没解决呢
我也碰到啦。。也是cs的程序连接数据库
最开始报
[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
我发现是那个数据库服务器的防火墙关啦后再连就报这个
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
还没解决正在找答案!
我也碰到啦。。也是cs的程序连接数据库
最开始报
[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
我发现是那个数据库服务器的防火墙关啦后再连就报这个
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
还没解决正在找答案!
#8
#9
LZ是不是调用了updateUI()来刷新啊,
#10
我也遇到了同样的问题啊, 不知楼主是怎样解决的 , 能告知与否?
#11
是因为显示调用updateUI()的原因
#12
我也遇到此问题 谁人解答
#13
也遇到同样问题,自己一直在查,
等待高手解决
等待高手解决
#14
发生了同样的问题,查到这篇老帖,看回复中有童鞋提到调用了updateUI导致,经检查确实如此,但是不调用又不行,会导致树叶的内容显示出现省略号,由于加载树叶启用了新线程,联想到swing的多线程机制,随后将updateUI()放入到 SwingUtilities.invokeLater()中进行,问题解决。
#15
StudentObjectStream obs=new StudentObjectStream();
List lst1=new ArrayList();
File f= new File(System.getProperty("user.dir")+"\\"+"student.obj");
if (f.exists())//当文件存在时,要先从文件中读出记录,再增加记录。
lst1=(List)obs.read1(System.getProperty("user.dir")+"\\"+"student.obj");
System.out.println(lst1.size());
Student s1=new Student(jComboBox1.getSelectedItem().toString(),jTextField1.getText(),jTextField2.getText(),jComboBox2.getSelectedItem().toString(),Integer.parseInt(jTextField3.getText()));
lst1.add(s1);
jComboBox1.setSelectedItem("计应");
jComboBox2.setSelectedItem("英语");
jTextField1.setText(null);
jTextField2.setText(null);
jTextField3.setText(null);
obs.write1(System.getProperty("user.dir")+"\\"+"student.obj", lst1);
请帮我看看这段代码哪错了。我的错误跟楼主一样
List lst1=new ArrayList();
File f= new File(System.getProperty("user.dir")+"\\"+"student.obj");
if (f.exists())//当文件存在时,要先从文件中读出记录,再增加记录。
lst1=(List)obs.read1(System.getProperty("user.dir")+"\\"+"student.obj");
System.out.println(lst1.size());
Student s1=new Student(jComboBox1.getSelectedItem().toString(),jTextField1.getText(),jTextField2.getText(),jComboBox2.getSelectedItem().toString(),Integer.parseInt(jTextField3.getText()));
lst1.add(s1);
jComboBox1.setSelectedItem("计应");
jComboBox2.setSelectedItem("英语");
jTextField1.setText(null);
jTextField2.setText(null);
jTextField3.setText(null);
obs.write1(System.getProperty("user.dir")+"\\"+"student.obj", lst1);
请帮我看看这段代码哪错了。我的错误跟楼主一样
#16
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(Unknown Source)
at javax.swing.plaf.basic.BasicTextAreaUI.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at javax.swing.JTextArea.getPreferredSize(Unknown Source)
at javax.swing.ScrollPaneLayout.layoutContainer(Unknown Source)
at java.awt.Container.layout(Unknown Source)
at java.awt.Container.doLayout(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validate(Unknown Source)
at javax.swing.RepaintManager.validateInvalidComponents(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
这就没有哪一行啊··
at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(Unknown Source)
at javax.swing.plaf.basic.BasicTextAreaUI.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at javax.swing.JTextArea.getPreferredSize(Unknown Source)
at javax.swing.ScrollPaneLayout.layoutContainer(Unknown Source)
at java.awt.Container.layout(Unknown Source)
at java.awt.Container.doLayout(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validate(Unknown Source)
at javax.swing.RepaintManager.validateInvalidComponents(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
这就没有哪一行啊··
#17
估计是你定义的表名与默认关键字是一样的!例如你的表名为“user”,而user是关键字,所以会出现这样的异常。。。
#18
初来乍论坛,还望大家多多关照,多多指教。