This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JEditorPane guarded blocks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JEditorPane guarded blocks" Watch "JEditorPane guarded blocks" New topic
Author

JEditorPane guarded blocks

ilkin esrefli
Greenhorn

Joined: Nov 01, 2007
Posts: 25

Hi, all ranchers, please help me.

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.

Thanks!!!


SCJP 5
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19654
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2153
    
    7
I have never tried it on a JEditorPane using HTML but you might be able to use the Protected Text Component.
ilkin esrefli
Greenhorn

Joined: Nov 01, 2007
Posts: 25

Thanks for your kind help. I solved the problem. Solution is placed here http://javam.wordpress.com/2010/07/22/jeditorpane-guarded-blocks
Regards!!!
 
 
subject: JEditorPane guarded blocks
 
Similar Threads
jsp:include needs to have "flush=true"
error - HTTP Status 404 - /EmailList/
Could it be Tomcat; I cant get my result on the screen
A href command not working
Resource not found