|
Quick Lists
|
|
Bug ID:
|
4128967
|
|
Votes
|
3
|
|
Synopsis
|
JTextPane throws StateInvariantError
|
|
Category
|
java:classes_swing
|
|
Reported Against
|
1.1.5
, swing1.0.2
|
|
Release Fixed
|
1.2(swing1.0.2)
|
|
State
|
10-Fix Delivered,
bug
|
|
Priority:
|
4-Low
|
|
Related Bugs
|
4129682
,
4129439
|
|
Submit Date
|
15-APR-1998
|
|
Description
|
Using JTextPane, add a single line of text to the
JTextPane, do not press return and then move the
Caret back to position 0, and try to add
some more text. I get a exception every time.
If you add more than one line of text the error
does not occure the first time you return to
position 0. But it happens the second time.
I have found using the home key works as long as
you are not on the first line allso alows you
to return once and add some text it also causes
a error on the second return and adding text.
The error has been reproduce using jdk 1.1.5 and
swing 1.0.1 under Windows 95.
The error has been reproduce using jdk 1.1.5 and
swing 1.0.1 under Windows NT 4
The error has been reproduce using jdk 1.1.5 and
swing 1.0.1 under Solaris 2.6.
Here is some example code that will produce the
error and copy of the exception I get.
import java.awt.Rectangle;
import java.awt.BorderLayout;
import com.sun.java.swing.JScrollPane;
import com.sun.java.swing.JViewport;
import com.sun.java.swing.JTextPane;
import com.sun.java.swing.ScrollPaneConstants;
import com.sun.java.swing.JPanel;
public class TestJTextPane extends JPanel
{
protected JScrollPane scroller = new JScrollPane();
protected JViewport theViewPort = scroller.getViewport();
protected JTextPane editor = new JTextPane();
public TestJTextPane()
{
super();
setLayout(new BorderLayout());
scroller.setViewportView(editor);
scroller.setVerticalScrollBarPolicy(
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS );
scroller.setHorizontalScrollBarPolicy(
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS );
Rectangle scrollerSize = new Rectangle(200,200);
scroller.setBounds(scrollerSize);
add("Center", scroller);
}
static public void main(String[] args)
{
java.awt.Frame testFrame =
new java.awt.Frame("Test for JTextPane");
TestJTextPane testEditorPane = new TestJTextPane();
testFrame.add("Center", testEditorPane);
testFrame.pack();
testFrame.show();
}
}
Exception occurred during event dispatching:
com.sun.java.swing.text.StateInvariantError: infinite loop in formatting
at
com.sun.java.swing.text.ParagraphView.rebuildRows(ParagraphView.java:163)
at
com.sun.java.swing.text.ParagraphView.layout(ParagraphView.java:127)
at
com.sun.java.swing.text.ParagraphView.insertUpdate(ParagraphView.java:596)
at
com.sun.java.swing.text.BoxView.insertUpdate(BoxView.java:311)
at
com.sun.java.swing.text.DefaultTextUI$RootView.insertUpdate(DefaultTextUI.java:834)
at
com.sun.java.swing.text.DefaultTextUI$UpdateHandler.insertUpdate(DefaultTextUI.java:1050)
at
com.sun.java.swing.text.AbstractDocument.fireInsertUpdate(AbstractDocument.java:137)
at
com.sun.java.swing.text.AbstractDocument.insertString(AbstractDocument.java:415)
at
com.sun.java.swing.JTextPane.replaceSelection(JTextPane.java:148)
at
com.sun.java.swing.text.DefaultEditorKit$DefaultKeyTypedAction.actionPerformed(DefaultEditorKit.java:650)
at
com.sun.java.swing.text.JTextComponent.processComponentKeyEvent(JTextComponent.java:1026)
at
com.sun.java.swing.JComponent.processKeyEvent(JComponent.java:1256)
at java.awt.Component.processEvent(Component.java:2138)
at java.awt.Container.processEvent(Container.java:894)
at java.awt.Component.dispatchEventImpl(Component.java:1764)
at java.awt.Container.dispatchEventImpl(Container.java:939)
at java.awt.Component.dispatchEvent(Component.java:1704)
at
java.awt.LightweightDispatcher.processKeyEvent(Container.java:1416)
at
java.awt.LightweightDispatcher.dispatchEvent(Container.java:1402)
at java.awt.Container.dispatchEventImpl(Container.java:926)
at java.awt.Window.dispatchEventImpl(Window.java:443)
at java.awt.Component.dispatchEvent(Component.java:1704)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:63)
(Review ID: 27201)
======================================================================
|
|
Work Around
|
none found yet
======================================================================
|
|
Evaluation
|
This was discovered just before 1.0 shipped and therefore didn't make
1.0. The problem was in BoxView, which blindly tried to access a child
element at index - 1 which is bad for an index of 0.
xxxxx@xxxxx 1998-04-20
|
|
Comments
|
Submitted On 05-NOV-1998
julie.b
This is again a problem in JFC 1.1
Beta 2 and Beta 3.
Julie
Submitted On 24-NOV-1998
schmeiss
This is also again a problem in Swing 1.1b3 in
conjunction with Netscape Com. 4.5 (Java 1.1.5).
When I use it whith the appletviewer (also Java 1.1.5)
it works fine... ,-(
Submitted On 16-FEB-1999
sarahv
this is a problem in swing 1.0.3 jre 1.1.6
(borland 2.1)
Submitted On 12-MAY-1999
jerhewet
I think all of these StateInvariantError's have something to do with the way
JTextPane performs word wrapping, myself...
I've just discovered that I can *finally* get JTextPane to accept large text
documents if I "build" the document from the bottom up (!).
Instead of appending each line of text as it comes in from the document to the
text that's already in the JTextPane, I load everything first and then use a
reverse loop (i = # of lines;i > -1;i--) to stick each line in at the top of
the document.
This way the document only reformats one line at a time for word wrapping,
instead of trying to reformat the entire document every time a line is appended
to the end of the existing text.
I suspect the people working on this need to rewrite their word wrapping
algorithm so that it starts at the beginning of that particular line of text,
and not at the beginning of the entire paragraph...
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |