Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.CellRendererPane.addImpl(CellRendererPane.java:85)
at java.awt.Container.add(Container.java:365)
at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1350)
at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1299)
at javax.swing.plaf.basic.BasicListUI.getPreferredSize(BasicListUI.java:566)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1632)
at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:769)
at java.awt.Container.layout(Container.java:1421)
at java.awt.Container.doLayout(Container.java:1410)
at java.awt.Container.validateTree(Container.java:1507)
at java.awt.Container.validateTree(Container.java:1513)
at java.awt.Container.validateTree(Container.java:1513)
at java.awt.Container.validateTree(Container.java:1513)
at java.awt.Container.validateTree(Container.java:1513)
at java.awt.Container.validate(Container.java:1480)
at java.awt.Window.dispatchEventImpl(Window.java:2473)
at java.awt.Component.dispatchEvent(Component.java:4413)
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)

经验:运行报错,从console控制台来看85行出错,传入了空值(NULL),所以返回源代码85行debug看值就行


阅读更多

异常处理,Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

05-30

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerExceptionrn at mor.stat.ui.MainFrame.editClbR(MainFrame.java:316)rn at mor.stat.ui.DynamicMenu.actionPerformed(DynamicMenu.java:334)rn at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)rn at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)rn at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)rn at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)rn at javax.swing.AbstractButton.doClick(AbstractButton.java:357)rn at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1225)rn at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1266)rn at java.awt.Component.processMouseEvent(Component.java:6216)rn at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)rn at java.awt.Component.processEvent(Component.java:5981)rn at java.awt.Container.processEvent(Container.java:2041)rn at java.awt.Component.dispatchEventImpl(Component.java:4583)rn at java.awt.Container.dispatchEventImpl(Container.java:2099)rn at java.awt.Component.dispatchEvent(Component.java:4413)rn at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4556)rn at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4220)rn at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4150)rn at java.awt.Container.dispatchEventImpl(Container.java:2085)rn at java.awt.Window.dispatchEventImpl(Window.java:2475)rn at java.awt.Component.dispatchEvent(Component.java:4413)rn at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)rn at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)rn at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)rn at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)rn at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)rn at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)rn at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)rnrnrnrnJComponent c = currentEditor.getContent();rn Dimension d = workPane.getSize();rn c.setPreferredSize(new Dimension(d.width - 10, d.height - 30));rn代码最后一行报错地址;

Graphics错误Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

09-07

当我运行下面的程序时,出现标题出现的错误 rnrnimport javax.swing.SwingUtilities;rnimport java.awt.BorderLayout;rnimport javax.swing.JPanel;rnimport javax.swing.JFrame;rnimport javax.swing.JLabel;rnimport java.awt.*;rnrnpublic class Main extends JFrame rnrn private static final long serialVersionUID = 1L;rnrn private JPanel jContentPane = null;rnrn private JLabel jLabel = null;rnrn public static void main(String[] args) rnrn SwingUtilities.invokeLater(new Runnable() rn public void run() rn Main thisClass = new Main();rn thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn thisClass.setVisible(true);rn rn );rn rnrnrn public Main() rn super();rn initialize();rn rnrnrn private void initialize() rn Graphics g;rn this.setSize(300, 200);rn this.setContentPane(getJContentPane());rn g=jContentPane.getGraphics();rn g.setColor(Color.black);rn g.fillRect(0, 0, 20, 20);rn this.setTitle("JFrame");rn rnrnrn private JPanel getJContentPane() rn if (jContentPane == null) rn rn jLabel = new JLabel();rn jLabel.setText("JLabel");rn jContentPane = new JPanel();rn jContentPane.setLayout(new BorderLayout());rn jContentPane.add(jLabel, BorderLayout.CENTER);rnrn rn return jContentPane;rn rnrnrnrnrn错误提示:rnException in thread "AWT-EventQueue-0" java.lang.NullPointerExceptionrn at com.zw.Main.initialize(Main.java:51)rn at com.zw.Main.(Main.java:38)rn at com.zw.Main$1.run(Main.java:26)rn at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)rn at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)rn at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)rn at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)rn at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)rn at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)rn at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)rn

Exception in thread "AWT-EventQueue-0"

05-03

在做个抓包+分析的简单软件,图形用户界面能出来了,但是一按“开始监听”就弹出了这一大串错:rnException in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no jpcap in java.library.pathrn at java.lang.ClassLoader.loadLibrary(Unknown Source)rn at java.lang.Runtime.loadLibrary0(Unknown Source)rn at java.lang.System.loadLibrary(Unknown Source)rn at jpcap.Jpcap.(Jpcap.java:151)rn at gui.ListenBegin.(ListenBegin.java:20)rn at gui.ListenBegin.getJpcap(ListenBegin.java:143)rn at gui.JCaptor.capturePacketsFromDevice(JCaptor.java:89)rn at gui.UserInterface.actionPerformed(UserInterface.java:217)rn at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)rn at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)rn at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)rn at javax.swing.DefaultButtonModel.setPressed(Unknown Source)rn at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)rn at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)rn at java.awt.Component.processMouseEvent(Unknown Source)rn at javax.swing.JComponent.processMouseEvent(Unknown Source)rn at java.awt.Component.processEvent(Unknown Source)rn at java.awt.Container.processEvent(Unknown Source)rn at java.awt.Component.dispatchEventImpl(Unknown Source)rn at java.awt.Container.dispatchEventImpl(Unknown Source)rn at java.awt.Component.dispatchEvent(Unknown Source)rn at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)rn at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)rn at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)rn at java.awt.Container.dispatchEventImpl(Unknown Source)rn at java.awt.Window.dispatchEventImpl(Unknown Source)rn at java.awt.Component.dispatchEvent(Unknown Source)rn at java.awt.EventQueue.dispatchEvent(Unknown Source)rn at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)rn at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)rn at java.awt.EventDispatchThread.pumpEvents(Unknown Source)rn at java.awt.EventDispatchThread.pumpEvents(Unknown Source)rn at java.awt.EventDispatchThread.run(Unknown Source)rn从字面上看是找不到jpcap库,可是我已经把wincap装上了,jpcap.jar、jpcap.dll也放对位置了,怎么会这样。。

没有更多推荐了,返回首页