I'm currently developing an Extension for OpenOffice. I'm using Java 1.6 and the OpenOffice SDK 4.1.2.
If I try to create a javax.swing.JTextPane, I get a NullpointerException in the Constructor of JTextPane.
public class Dialog extends javax.JFrame {
private final JTextPane jTextPane;
private final JTable jTable;
public Dialog() {
jTable = new JTable();
jTextPane = new JTextPane();
}
}
The Dialog is initialized in another Thread:
public class DialogManager {
private static JournalDialog journalDialog;
public void showDialog() {
Thread startThread = new Thread(new Runnable() {
@Override
public void run() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
dialog = new Dialog();
...
}
}
}
}
}}
The creation of JTable works fine, but in the next line I get a Nullpointerexception
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.util.Hashtable.put(Unknown Source)
at javax.swing.JEditorPane.registerEditorKitForContentType(Unknown Source)
at javax.swing.JEditorPane.registerEditorKitForContentType(Unknown Source)
at javax.swing.JEditorPane.loadDefaultKitsIfNecessary(Unknown Source)
at javax.swing.JEditorPane.getKitTypeRegistry(Unknown Source)
at javax.swing.JEditorPane.getEditorKitClassNameForContentType(Unknown Source)
at javax.swing.JTextPane.<init>(Unknown Source)
at .gui.Dialog.<init>(Dialog.java:159)
at .gui.DialogManager$6$1.run(DialogManager.java:334)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
I hope someone has an idea what causes this exception. I tried to run the extension in Java 1.7 and 1.8, but there is the same issue.
Best regards
Update 16.08.2016: If I add a JTexPane over the Netbeans Palette into the Designer, it works. Only the initialisation in the constructor fails.