Drag/dropping entities into a JTextPane
At the moment I need to be able to have a text pane represent a report. The report will need to store entities, so I will need to use icons, labels, or something to represent them in the report. My goal in doing this is representing "entities" inside a report, and not allowing the user to fudge with them.
I.e., here is what I don't want to happen. Let's say my entities look like [Lewis, Jerry 234324234]. I will need to parse those out later, and I don't want the user to be able to "simulate" them by typing in brackets, a name, and a number for example; and thereby break my parsing scheme.
My current solution is to drag and drop JLabels into the text pane and use them to represent entities. The solution still seems somewhat crude to me. They do have the advantage of not being fabricated by a user, and if you back space over them the entire thing disappears which is necessary when dealing with entities.
But there has got to be a better way. I haven't used JEditorPanes much. My only other idea is inserting some kind of atomic HTML tag that is not reproducible by the user.
I need a way to represent entities atomically in a JTextPane, so they can be parsed out later.