Skip to content Skip to sidebar Skip to footer

HyperlinkUpdate() Gives Me NullPointerException Every Time I Click A Hyperlink In The JEditorPane?

I just want to add that the initial file loaded is a javadoc that has the names of all the classes, I want it to display the corresponding page for each class when I click on the h

Solution 1:

But where are you getting this NullPointerException?

I run your example code, and got NullPointerException on:

htmlPane.setPage(event.getURL());

so htmlPage field was null.

when added line:

this.htmlPane = htmlPane;

in:

public void frame() {
    JFrame frame = new JFrame("asdd");
    JLabel l = new JLabel("asdsada");
    try {
        JEditorPane htmlPane = new JEditorPane(url);
        this.htmlPane = htmlPane;

I can now click on any link (in my case in "http://www.google.com/")


Post a Comment for "HyperlinkUpdate() Gives Me NullPointerException Every Time I Click A Hyperlink In The JEditorPane?"