Hi everybody.
I'm trying to display web page that located in my computer or just (google web page).
But everytime I'mgetting nullpointer exception.
Please help me to figure out the problem.
here is the absolute path that I'm using:
serg@serg-PORTEGE-Z835:~$ find $PWD -type f -name test1.html
/home/serg/Projects/java/GUI/src/its/TestData/test1.html
But the error that I'm getting is null pointer exception
I put a coments in the code so you can see were is the error
(By the way I just start learning GUI, so the problem could be in some other statement =) )
package its.HTML;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
public class SimpleHTMLFrame extends JFrame{
private JEditorPane ediPane;
//private static String HTMLSource = "http://www.google.com";
// I think this cause error
private static String HTMLSource = "/home/serg/Projects/java/GUI/src/its/TestData/test1.html";
private static String workingDir;
public SimpleHTMLFrame(String URLname) {
this.setSize(210,300);
this.setLocation(200,200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(400,400);
this.setVisible(true);
this.setTitle("HTML display");
try {
ediPane = new JEditorPane(HTMLSource);
ediPane.setEditable(false);
} catch (Exception e) {
//ERROR
// I have Exception in thread "main" java.lang.NullPointerException in here
this.getContentPane().add(ediPane);
}
}
public static void main(String[] args) {
SimpleHTMLFrame shf = new SimpleHTMLFrame(HTMLSource);
}
}