jta.setCaretPosition抛出异常NullPointerException?
下面语句实现文本区域刷新显示功能。
mMenu.jta.setCaretPosition(mMenu.jta.getText().length())
在运行过程中,会抛出空指针错误。NullPointerException
在文本区域TextArea中,使用append添加文字,有最大长度限制,如何解决呢?
我是在一定行数后(如1000行)再清空(setText(""));
java.lang.NullPointerException
at javax.swing.text.PlainView.updateMetrics(Unknown Source)
at javax.swing.text.PlainView.getPreferredSpan(Unknown Source)
at javax.swing.plaf.basic.BasicTextUI$RootView.getPreferredSpan(Unknown Source)
at javax.swing.plaf.basic.BasicTextUI.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.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)