This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I am using shef swing html editor, it uses JEditorPane swing component. I want to add feature for guard from change(delete, update) some signed block of html like netbeans editor. Netbeans editor prevent some parts of code from changing.
For example we have html as
I want to prevent <p> block from update and delete, other parts can change.
I need your help.
Use a DocumentFilter around the JEditorPane's Document. You'll need to do quite some checking and coding in there; insertString needs to check if the position is allowed, remove needs to remove everything except the blocked part, as does replace.