The relevant area of the Java Tutorial is here:
http://java.sun.com/docs/books/tutor...ents/text.html
Something like this might help:
JEditorPane editorPane = new JEditorPane();
// Get a URL somehow
java.net.URL url = ClassLoader.getSystemClassLoader().getResource("readme.html");
editorPane.setPage(url);
HTMLDocument htmlDoc = (HTMLDocument) editorPane.getDocument();
htmlDoc.addDocumentListener(
new DocumentListener(){
public void changedUpdate(DocumentEvent e){
// handle DocumentEvent's
}
public void insertUpdate(DocumentEvent e){
// handle DocumentEvent's
}
public void removeUpdate(DocumentEvent e){
// handle DocumentEvent's
}
};
);
Pseudocode, with links:
call the getDocument() method on your JEditorPane:
http://java.sun.com/j2se/1.4/docs/ap...ditorPane.html
That will give you one of these:
http://java.sun.com/j2se/1.4/docs/ap.../Document.html
But you can cast it to one of these:
http://java.sun.com/j2se/1.4/docs/ap...LDocument.html
Then you can use the addDocumentListener method of HTMLDocument to listen for these:
http://java.sun.com/j2se/1.4/docs/ap...mentEvent.html
using a class you have created that implements this:
http://java.sun.com/j2se/1.4/docs/ap...tListener.html