Draggable & Resizable Editors
Posted
by Geertjan
on Oracle Blogs
See other posts from Oracle Blogs
or by Geertjan
Published on Wed, 21 Nov 2012 13:48:25 +0000
Indexed on
2012/11/21
17:08 UTC
Read the original article
Hit count: 294
/NetBeans IDE
Thanks to a cool tip from Steven Yi (here in the comments to a blog entry), I was able to make a totally pointless but fun set of draggable and resizable editors:
What you see above are two JEditorPanes within JPanels. The JPanels are within ComponentWidgets provided by the NetBeans Visual Library, which is also where the special border comes from. The ComponentWidgets are within a Visual Library Scene, which is within a JScrollPane in a TopComponent.
Each editor has this, which means the NetBeans Java Editor is bound to the JEditorPane:
jEditorPane1.setContentType("text/x-java"); EditorKit kit = CloneableEditorSupport.getEditorKit("text/x-java"); jEditorPane1.setEditorKit(kit); jEditorPane1.getDocument().putProperty("mimeType", "text/x-java");
A similar thing is done in the other JEditorPane, i.e., it is bound to the XML Editor. While the XML Editor also has code completion, in addition to syntax coloring, as can be seen above, this is not the case for the JEditorPane bound to the Java Editor, since the JEditorPane doesn't have a Java classpath, which is needed for Java code completion to work.
© Oracle Blogs or respective owner