Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Null Pointer Exceptions after modifying attributes of Document element

15 views
Skip to first unread message

Steve Hannah

unread,
Apr 27, 2003, 6:53:42 PM4/27/03
to
I have been trying to make a source code editor with syntax hilighting
using JTextPane and a custom subclass of AbstractDocument. I have
overridden the insertString() and remove() methods of Abstract
document so that modifications are passed to a formatting thread to
perform syntax hilighting. I beleive that I am using readLock() and
writeLock() appropriately so as to lock the document while I am
coloring it with the formatting thread, but I am frequently getting
the following:

java.lang.NullPointerException
at javax.swing.text.FlowView$FlowStrategy.createView(FlowView.java:569)
at javax.swing.text.FlowView$FlowStrategy.layoutRow(FlowView.java:442)
at javax.swing.text.FlowView$FlowStrategy.layout(FlowView.java:398)
at javax.swing.text.FlowView.layout(FlowView.java:182)
at javax.swing.text.BoxView.setSize(BoxView.java:379)
at javax.swing.text.BoxView.updateChildSizes(BoxView.java:348)
at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:330)
at javax.swing.text.BoxView.layout(BoxView.java:682)
at javax.swing.text.BoxView.setSize(BoxView.java:379)
at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(BasicTextUI.java:1598)
at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java:1317)
at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:635)
at apple.laf.AquaTextPaneUI.paintSafely(AquaTextPaneUI.java:36)
at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:769)
at javax.swing.plaf.basic.BasicTextUI.update(BasicTextUI.java:748)
at javax.swing.JComponent.paintComponent(JComponent.java:541)
at javax.swing.JComponent.paint(JComponent.java:808)
at javax.swing.JComponent._paintImmediately(JComponent.java:4678)
at javax.swing.JComponent.paintImmediately(JComponent.java:4477)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)


The above readout is from jre 1.4.1 on Mac OS 10.2 but I get a similar
readout when running it on windows xp.

The hilighting works when I am just adding text to the end of the
document, but when I try to insert text to the middle or beginning of
the document, these errors come up.

Since I have not made any custom views for this project, I am at a bit
of a dead end on where to look for the source of the problems. What
are the common reasons for such exceptions.

Thanks in advance.

Steve Hannah
sha...@sfu.ca

0 new messages