I would like to know how can I extend JEditorPane (or any other swing text editing component) to handle rectangle (column) selection mode. It is a well known feature in current text editors where you can select multiple lines (rows) starting from an offset (column) and ending by an offset (column) which look like selecting a rectangle of text, and then what you type will overwrite the selection in each line (row) concurrently.
One idea was to override the selection and create fake selection by highlighting each line in rectangle form by following the mouse events, and keeping track of such information to use it when typing. However, I am not quit sure how to override the selection and track the mouse, nor how to redirect typing to affect each line.
Any help in any form would be appreciated.
Found out this little code snippet, that involves a Custom
Caret(to handle the fragmented selection) andHighlighter(to show the fragments):Anyway, I’ve never run that code (it’s Stanislav’s).