Was ist an der Zeile 37 verkehrt?
Habe sie wortwörtlich aus einem Fachbuch.
er gibt eine Exception aus..
Exception in thread "main" java.lang.NullPointerException
at view.MyFrame.<init>(MyFrame.java:37)
at doc.Main.main(Main.java:11)
DANKE schon im Vorraus!!
Habe sie wortwörtlich aus einem Fachbuch.
er gibt eine Exception aus..
Exception in thread "main" java.lang.NullPointerException
at view.MyFrame.<init>(MyFrame.java:37)
at doc.Main.main(Main.java:11)
Java:
package view;
import java.awt.Dimension;
import java.awt.HeadlessException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.UIManager;
public class MyFrame extends JFrame {
private JEditorPane ep_maincontent;
private JScrollPane sp_maincontent;
public MyFrame() throws HeadlessException {
super();
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
//this.setLayout(null);
this.pack();
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
} catch(Exception e) {
System.out.println("Error setting native LAF: " + e);
}
File file = new File("d:\\test.txt");
try {
FileReader fr = new FileReader(file);
try {
ep_maincontent.read(fr, null);
} catch (IOException e) {
System.out.println("IOException");
e.printStackTrace();
}
} catch (FileNotFoundException e) {
System.out.println("FileNotFoundException");
e.printStackTrace();
}
this.setSize(500, 500);
ep_maincontent = new JEditorPane();
sp_maincontent = new JScrollPane(ep_maincontent);
sp_maincontent.setSize(400, 400);
this.add(sp_maincontent,"Center");
}
}
DANKE schon im Vorraus!!