陈建华的博客
专注web开发
java图形界面报错 paintCell BasicTableUI
2016-11-07 22:37:07   阅读617次

错误代码如下:

Exception occurred during event dispatching:

java.lang.NullPointerException

    at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2067)

    at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1977)

    at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1773)

    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.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1472)

    at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1403)

    at javax.swing.RepaintManager.paint(RepaintManager.java:1217)

    at javax.swing.JComponent._paintImmediately(JComponent.java:5070)

    at javax.swing.JComponent.paintImmediately(JComponent.java:4880)

    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:803)

    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:714)

    at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:694)

    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:269)

    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)

    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:178)

    at java.awt.Dialog$1.run(Dialog.java:1047)

    at java.awt.Dialog$3.run(Dialog.java:1099)

    at java.security.AccessController.doPrivileged(Native Method)

    at java.awt.Dialog.show(Dialog.java:1097)

    at java.awt.Component.show(Component.java:1447)

    at java.awt.Component.setVisible(Component.java:1400)

    at java.awt.Window.setVisible(Window.java:824)

    at java.awt.Dialog.setVisible(Dialog.java:987)

    at net.*****.*******.ui.dbmeger.xxxxxx.<init>(xxxxxxx.java:332)

    at net.*****.*******.ui.dbmeger.xxxxxxx$1.actionPerformed(xxxxxxxxx.java:142)

    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)

    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)

    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)

    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)

    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)

    at java.awt.Component.processMouseEvent(Component.java:6134)

    at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)

    at java.awt.Component.processEvent(Component.java:5899)

    at java.awt.Container.processEvent(Container.java:2023)

    at java.awt.Component.dispatchEventImpl(Component.java:4501)

    at java.awt.Container.dispatchEventImpl(Container.java:2081)

    at java.awt.Component.dispatchEvent(Component.java:4331)

    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4301)

    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3965)

    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3895)

    at java.awt.Container.dispatchEventImpl(Container.java:2067)

    at java.awt.Window.dispatchEventImpl(Window.java:2458)

    at java.awt.Component.dispatchEvent(Component.java:4331)

    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)

    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)

    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)

    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)

    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)

    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)

    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

原因分析:

我的swing界面上有一个table。但是我在创建table的时候同时有新建了一个线程去数据库查询数据。查询的数据也会直接给table赋值。这样table的状态就不对了。其实就是界面在多个线程同时操作了。

解决办法就是安全线程。



-----------------------------------------------------
转载请注明来源此处
原地址:#

-----网友评论----
暂无评论
-----发表评论----
微网聚博客乐园 ©2014 blog.mn886.net 鲁ICP备14012923号   网站导航