這是我班的構造函數。使用以下代碼:爲什麼我在這裏得到例外?
public tester {
setTitle("tester");
initComponents();
jTextArea6.setEditable(false);
jEditorPane1.setEditable(false);
}
每件事情都很好。但有了這個代碼,
public tester() {
setTitle("tester");
jTextArea6.setEditable(false);
jEditorPane1.setEditable(false);
initComponents();
}
我得到以下異常:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at tester.tester.<init>(tester.java:31)
at tester.tester$35.run(tester.java:1389)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:660)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
爲什麼會是這樣?
也許你正在嘗試設置不存在的可編輯(false)對象? – ascanio
爲了更清晰起見,請考慮發佈[SSCCE](http://pscode.org/sscce.html)。如果這個問題已經這樣做了,那麼正在回答的人就不必妄下結論。 –