NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Editor Java in a JEditorPane

 
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users
View previous topic :: View next topic  
Author Message
mathieu



Joined: 29 Jul 2010
Posts: 13

PostPosted: Wed Dec 15, 2010 11:27 pm    Post subject: Editor Java in a JEditorPane Reply with quote

Hi,

I fail in getting syntax highlighting and completion in a JEditorPane. I include the classical following code:
Code:

        JEditorPane editorPane = new JEditorPane();
        EditorKit kit = CloneableEditorSupport.getEditorKit("text/x-groovy");
        editorPane.setEditorKit(kit);
        FileObject fob;
        try {
            fob = FileUtil.createMemoryFileSystem().getRoot().createData("tmp",
                    "groovy");
            DataObject dob = DataObject.find(fob);
            editorPane.getDocument().putProperty(
                    Document.StreamDescriptionProperty,
                    dob);
      DialogBinding.bindComponentToFile(fob, 0, 0, editorPane);
            editorPane.setText("package dummy;");
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }


It fails giving the following error:

java.lang.NullPointerException
at org.netbeans.modules.parsing.impl.DialogBindingEmbeddingProvider.getEmbeddings(DialogBindingEmbeddingProvider.java:67)
at org.netbeans.modules.parsing.impl.SourceCache.refresh(SourceCache.java:273)
at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:650)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:90
)


The error just occurs at the moment of the binding. If I comment DialogBinding.bindComponentToFile(fob, 0, 0, editorPane), I don't have any exception and I get a simple editor (with the red margin in the right hand side) but without any highlight syntax nor completion.
The behavior is the same using java or groovy binding. An idea of what is wrong ?

One more thing, the list of imports:

Code:

import javax.swing.text.Document;
import javax.swing.text.EditorKit;
import org.netbeans.api.editor.DialogBinding;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.loaders.DataObject;
import org.openide.text.CloneableEditorSupport;


Thanks for helping.
Mathieu
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo