首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

jta.setCaretPosition抛出异常NullPointerException

2014-01-26 
jta.setCaretPosition抛出异常NullPointerException?下面语句实现文本区域刷新显示功能。 mMenu.jta.setCare

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)         

热点排行