I am trying to fix a problem on inserting a span tag into an existing html page (in an EDITABLE JEditorPane).
Assuming the cells in a table (3 rows, 2 columns) are numbered from 1 to 6, with cell one being the top left most, cell 2 top right, cell 3 middle left, etc.
1. Inserting the text "<span></span>" in cell 4 causes during any attempt to later type into cell 5 the characters to be appended instead into cell 4, directly after the close span tag.
2. The insertion in the first place behaves strange. If I have the caret positioned for cell 5 so that I can insert there
(via the function void javax.swing.text.html.HTMLEditorKit.insertHTML(HTML Document doc, int offset, String html, int popDepth, int pushDepth, Tag insertTag) )
even though the caret position is visible in cell 5, the insertion seems to take place in cell 4.
I can sort of compensate for this by adding 1 to the offset. However, then when inserting into a line of text, for example, "the quick red fox jumped over the lazy dog"
I insert directly before the 'j' in 'jumped', the insertion looks like this "the quick red fox j<span>..</span>umped over the lazy dog"
So that is no solution.
IMPORTANT! Just to prove it is not the span tag causing the trouble, if this span tag already exists in a cell on 'Load' of the html file, the strange behaviour is not observed.
Something is going wrong here. It is me? Or is it a bug?
Here is a test app, and the test html you can use (place in current directory).
Please test like this:
1. run application (the html should be loaded into the pane)
2. the span tag is programmed to automatically insert at cell 4 (by using the +1 method on the insert)
3. another span tag was already existing in the html file, at cell 8
4. Attempt to type into cell 5
result: the text appears instead at cell 4
5. Type into cell 9
result: the text correctly is entered into cell 9
geez... All i am getting is rules here, and no help.
And i seem to break them all.
I am sorry. Didn't mean it.
I feel I am a good net citizen, and would of course share any answer(s) on any or all forums I post on. That goes without saying.