Problems and Solutions:

 

Problem

How It Was Solved

The cursor was huge in size, and some text disappeared while moving the cursor inside a tree view.

Modified the size requirements of tree view along the x-axis.

A null pointer exception was thrown when trying to move the cursor past the end of the document.

A custom cursor was installed which handled BadLocationException.

The cursor was hidden behind delimiter views.

Re-implemented the paint() method of the cursor, and forced it to draw the cursor 2 pixels to the left of the actual position of delimiter views.

Delimiter tags overlapped.

Changed the vertical alignment of HiddenTagView.

An ArrayIndexOutOfBoundException was thrown while removing some elements, and StateInvariontError was thrown while removing other elements.

The reason was that the element structure was not getting updated after removal, so modified the element structure in the removeUpdate() method of XMLDocument.

View structure was not getting updated properly while inserting a new element.

The reason was that the Element changes generated by DefaultStyledDocument were not proper. To solve the problem, I completely changed the logic of element insertion, and directly modified the DOM structure. Now, Remove Element stopped working! So changed the logic of Remove Element and modified DOM structure there as well.

Cursor appeared at the beginning of the document after every element insertion/deletion.

Saved the position of the cursor before modifying the DOM structure and restored it after modification.