Mars
Mars

Reputation: 4307

JEditorPane onReady?

how can I perform an action when the JEditorPane is done loading a webpage from an url? is this even possible? i'm unable to find anything about this online :s

thank you

Upvotes: 2

Views: 832

Answers (1)

camickr
camickr

Reputation: 324157

Try using a PropertyChangeListener:

JEditorPane html = new JEditorPane();
html.addPropertyChangeListener("page", this);
try
{
    html.setPage( new URL(webURL.getText()) );
}
catch(Exception exc)
{
    System.out.println(exc);
}

...

public void propertyChange(PropertyChangeEvent e)
{
    System.out.println("Page Loaded");
}

At one time the event would be fired after the initial page was loaded but before all the child images where loaded. However I just did a quick test and it appears to fire now after the page and images have been loaded.

Upvotes: 2

Related Questions