Bug 19862 - Swing JTextField fails with StringIndexOutOfBoundsException
Summary: Swing JTextField fails with StringIndexOutOfBoundsException
Status: RESOLVED FIXED
Alias: None
Product: classpath
Classification: Unclassified
Component: swing (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: 0.18
Assignee: Thomas Fitzsimmons
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-09 17:40 UTC by Norman Hendrich
Modified: 2005-10-16 01:47 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-05-14 21:08:25


Attachments
testcase (3.36 KB, text/plain)
2005-02-09 17:43 UTC, Norman Hendrich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Norman Hendrich 2005-02-09 17:40:33 UTC
Entering text into a JTextField fails with an StringIndexOutOfBoundsException,
triggered by a problem in GapContent or AbstractDocument.getText().
Tested with gcc-4.0-20050130 snapshot and a current (2005.02.09) cvs
checkout of gui-branch-20040128:

java.lang.StringIndexOutOfBoundsException
   at java.lang.StringBuffer.substring(int, int) (/usr/lib/libgcj.so.6.0.0)
   at javax.swing.text.GapContent.getString(int, int)
(/usr/lib/lib-javax-swing.so.0.0.0)
   at javax.swing.text.AbstractDocument.getText(int, int)
(/usr/lib/lib-javax-swing.so.0.0.0)
   at javax.swing.text.FieldView.getPreferredSpan(int)
(/usr/lib/lib-javax-swing.so.0.0.0)


Testcase attached. Note that the calculator functionality is stripped off
to make the testcase shorter. (This is slightly unfair for gcj, because
the expression parser does work with gcj.)
Comment 1 Norman Hendrich 2005-02-09 17:43:59 UTC
Created attachment 8158 [details]
testcase

Just compile the class, then try entering an expression into the
JTextField on the bottom of the main window and press <return> or
press the <Execute> button.

Note that the program also triggers a few other bugs; it can be
tricky to tranfer the keyboard focus to the textfield in the 
first place....
Comment 2 Andrew Pinski 2005-02-12 22:35:51 UTC
Confirmed.
Comment 3 Roman Kennke 2005-06-03 14:54:13 UTC
I have mostly fixed JTextArea in GNU Classpath. I think this can be close as
soon as it is merged into GCJ.
Comment 4 Thomas Fitzsimmons 2005-08-24 19:30:38 UTC
Fixed.  Closing.