The syntax coloring is very basic, but that's the syntax coloring in my current version of NetBeans IDE 6.0. The code that you see above is the constructor of the TopComponent, which associates the NetBeans Java Editor with the JEditorPane.
One needs to create a Java file somewhere, as shown above. Would be better, and is possible I think, to create the file in memory. I've also noticed that the code completion doesn't work in some cases, such as sometimes when the JEditorPane is empty. So one could use the setText() method on the JEditorPane to add some text programmatically.
And now I can use code completion, as well as some of the other features of the NetBeans Java Editor. Here's what I see when I press Ctrl-Space, i.e., code completion, in the Exception statement below:
Would be nice if this were also possible in other Swing components, but without being able to set a MIME type, that's not possible, it seems. So, for example, a JTextField could not be used in this way.
And: Is it even possible to create a component (or "modify" a JEditorPane), which highlights HTML, CSS and PHP at once?
I need add xml/xsd support for my JEditorPane component.
Therefore i wrote simple TopComponent code:
private javax.swing.JEditorPane jep;
private void initPane() {
EditorKit kit = CloneableEditorSupport.getEditorKit("text/xml");
jep.setEditorKit(kit);
jep.setText(getText());
}
All needed schemas included in DTD's and Schema's Catalog.
But there are problem if getText() contains xsd-code (for example:
<tag xmlns:xsi=...
xsi:schemaLocation=...
xmlns=...>
if i use Ctrl+Space then have exception:
java.lang.AssertionError: Null file object.
at org.netbeans.modules.xml.retriever.catalog.Utilities.createModelSource(Utilities.java:622)
at org.netbeans.modules.xml.retriever.catalog.Utilities.getModelSource(Utilities.java:609)
at org.netbeans.modules.xml.schema.completion.util.DefaultModelProvider.getCompletionModel(DefaultModelProvider.java:102)
at org.netbeans.modules.xml.schema.completion.util.DefaultModelProvider.getModels(DefaultModelProvider.java:87)
at org.netbeans.modules.xml.schema.completion.util.CompletionContextImpl.initModels(CompletionContextImpl.java:488)
at org.netbeans.modules.xml.schema.completion.CompletionQuery.getCompletionItems(CompletionQuery.java:102)
at org.netbeans.modules.xml.schema.completion.CompletionQuery.query(CompletionQuery.java:85)
at org.netbeans.spi.editor.completion.support.AsyncCompletionTask.run(AsyncCompletionTask.java:218)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986)
)
if i use standard netbeans xml editor then my schemas assists show up by Ctrl+Space
Can you help me?
Hi
I want to view an html page in my swing application that i used drag and drop in netbeans. im jst a student...please help