views:

9

answers:

1

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

A: 

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.

camickr