NetBeans 6 delivers great updates to the Matisse GUI builder. Spend a few minutes with Roman Strobl and get an expert briefing on what's new and what has changed. (sponsored)
In this, the third and final installation of Andres' Introduction to Groovy series, you learn about how Groovy handles variable numbers of arguments, named parameters, currying, and more about Groovy operators. Including, some new operators.
Swing Fuse (actually just Fuse), is a framework designed to make it easier to create your own custom desktop components. In this article, Daniel Spiewak shows you how to get started and provides sample source code you can download.
Willam Louth shows how he uses JXInsight Probes to investigate probable performance issues with code bases that he is not familiar with. He also highlights possible pitfalls in creating a benchmark, as well as in the analysis of results.
Someone creating a standalone XML editor in Java might assume that there is an equivalent to the
javax.swing.text.html
package for XML, specifically, that the JDK provides an
editor kit
for XML files. But it doesn't. No
XMLEditorKit
means one can either create one's own or use one of the many that are out there. Type "XMLEditorKit" in Google and prepare yourself for a flood of alternatives, with a greater or lesser feature set. Other identifiable differences relate, not surprisingly, to whether or not the 3rd party library is actively being developed, and to what extent, if any, there's documentation and other support (free or otherwise) available.
Below, a quick tour through some of the alternatives, in no particular order.
org.bounce.text.xml.XMLEditorKit
.
The first piece of good news is that
someone
blogged positively about this class as recently as September this year. That's a proof of life, as far as I am concerned. Another big plus is the fact that there's a
complete sample
on the related site. The class is provided by
Bounce
, which is "a set of Java and Swing extensions, including layout managers, like a FormLayout and CenterLayout, image filters, a comprehensive messaging mechanism, an XMLEditorKit with syntax highlighting and automatic indentation, and more". Another big bonus is that it is free. Here is my Bounce XML Editor in action:
The Bounce site states that its XMLEditorKit has configurable syntax highlighting, automatic indentation, end-tag completion, and more. The "configurable" part of that statement is achieved as follows, in this case for auto indentation:
XMLDocument.AUTO_INDENTATION_ATTRIBUTE, new Boolean( true));
Looks nice, works, well, has documentation, is free, and so on. If I were handing out stars, I'd give a big thumbs up here (that is, 5 out of 5 stars).
kiyut.swing.text.xml.XMLEditorKit
.
What's interesting about this one is that if you were asleep for half a second last week, you wouldn't have known this even exists. It is a new XMLEditorKit added on Friday to the code repository of the
Apache Batik Project
, as
org.apache.batik.util.gui.xmleditor
. You can
read the related issue here
. It comes from Tonny Kohar and his
Sketa Project
, by Kiyut in Indonesia. Here's the package with its classes, so you can see that it is really focused very specifically on an XMLEditorKit (unlike Bounce, above, for example, which provides other stuff too):
And here's my first editor using this Batik/Kiyut class:
And here's how it works:
public XMLEditorJFrame() {
try {
initComponents();
xmlEditorPane.setEditorKitForContentType(XMLEditorKit.XML_MIME_TYPE, new XMLEditorKit());
xmlEditorPane.setContentType(XMLEditorKit.XML_MIME_TYPE);
File file = new File("/home/geertjan/Desktop/text.xml");
xmlEditorPane.read(new FileReader(file), file);
} catch (IOException ex) {
Logger.getLogger(XMLEditorJFrame.class.getName()).log(Level.SEVERE, null, ex);
}
}
Simple, effective, gets the job done, and I hope Tonny and others will continue to work on it. As one can see, it doesn't seem to have the variations in color as the Bounce editor does, although possibly it could be configured like that too, I don't know.
com.japisoft.xmlpad.editor.XMLEditorKit
.
I like this one a lot. Here, after following the tutorial, is my new XML Editor... Unfortunately, though, as I am typing this, a message pops up saying: "This is a non registered JXMLPad Version." And then it tells me to go to the site to register it. Nevertheless, this is what I have now thanks to this cool library:
Most of the functionality is simply configurable, such as this line for coloring:
One can also easily add actions, in addition to a standard declarative set. Pity the
prices
do not correlate with the content of my wallet. Apart from that, really cool.
Two others,
smacs.xngr.browser.editor.XMLEditorKit
and
cz.fimuni.xsrom.text.xml.XMLEditorKit
, look interesting, but couldn't find anywhere to download them. They seem to come from universities, are possibly internal projects, and so on. (Maybe the first is an early version of Bounce, since Edwin Dankert seems to be behind both.) Would've liked to have tried them, though!
Note:
The
NetBeans Platform
could also be used in this context, since one can detach the NetBeans IDE XML Editor and use it in one's own application. Plus, there are specific API classes that can extend it further.
Here
is a thread about opening a file in such an XML Editor and
here
is a tutorial about extending an XML editor. The benefit of this approach is that one doesn't need to write the editor from scratch. Plus, pluggability means anyone can add to your editor very easily by making additional modules available with new features that can be installed via a Plugin Manager, which is also simply a matter of bundling it up with the editor.
For completion's sake, there's also an XMLEditorKit by
Threshold Computer Systems, Inc
, although a message dated 01/11/2007 says: "XMLEditorKit 1.0 and sample XMLEditor are temporarily unavailable for download." Note that it is a commercial product. Also,
here
is the related announcement on Java Ranch, from 2003, describing the full functionality (at that time, anyway).
I've also found one or two references to
org.apache.interop.common.ui.xmleditorkit
, though only in a mailing list, and it's not clear whether it is still being maintained. Finally, the
Xylia Tookit
seems to have something available in this area too, although
this PDF document about it
was written in 2003, so maybe it's no longer with us anymore.
At the end of this overview, I hope to hear from developers who have tried some or all of the above. Plus, there are bound to be some I haven't tracked down. What have your experiences been in this area? Any recommendations?
I had been using bounce as well . I am not 100% happy with it some times the text scroll to a random(?) position, but it is workable. I set the colors like IE uses it and got a view my users are familiar with
The kiyut.swing.text.xml.XMLEditorKit package is also have syntax highlight and configurable color schemes. Just override the XMLContext.java to adjust the default xml syntax color highlight. It is just simple a Map (HashMap)
What's the Deal with XMLEditorKit?
At 2:35 PM on Dec 1, 2007, Geertjan wrote:
Fresh Jobs for Developers Post a job opportunity
Below, a quick tour through some of the alternatives, in no particular order.
org.bounce.text.xml.XMLEditorKit . The first piece of good news is that someone blogged positively about this class as recently as September this year. That's a proof of life, as far as I am concerned. Another big plus is the fact that there's a complete sample on the related site. The class is provided by Bounce , which is "a set of Java and Swing extensions, including layout managers, like a FormLayout and CenterLayout, image filters, a comprehensive messaging mechanism, an XMLEditorKit with syntax highlighting and automatic indentation, and more". Another big bonus is that it is free. Here is my Bounce XML Editor in action:
The Bounce site states that its XMLEditorKit has configurable syntax highlighting, automatic indentation, end-tag completion, and more. The "configurable" part of that statement is achieved as follows, in this case for auto indentation:
Looks nice, works, well, has documentation, is free, and so on. If I were handing out stars, I'd give a big thumbs up here (that is, 5 out of 5 stars).
kiyut.swing.text.xml.XMLEditorKit . What's interesting about this one is that if you were asleep for half a second last week, you wouldn't have known this even exists. It is a new XMLEditorKit added on Friday to the code repository of the Apache Batik Project , as org.apache.batik.util.gui.xmleditor . You can read the related issue here . It comes from Tonny Kohar and his Sketa Project , by Kiyut in Indonesia. Here's the package with its classes, so you can see that it is really focused very specifically on an XMLEditorKit (unlike Bounce, above, for example, which provides other stuff too):
And here's my first editor using this Batik/Kiyut class:
And here's how it works:
public XMLEditorJFrame() { try { initComponents(); xmlEditorPane.setEditorKitForContentType(XMLEditorKit.XML_MIME_TYPE, new XMLEditorKit()); xmlEditorPane.setContentType(XMLEditorKit.XML_MIME_TYPE); File file = new File("/home/geertjan/Desktop/text.xml"); xmlEditorPane.read(new FileReader(file), file); } catch (IOException ex) { Logger.getLogger(XMLEditorJFrame.class.getName()).log(Level.SEVERE, null, ex); } }Simple, effective, gets the job done, and I hope Tonny and others will continue to work on it. As one can see, it doesn't seem to have the variations in color as the Bounce editor does, although possibly it could be configured like that too, I don't know.
com.japisoft.xmlpad.editor.XMLEditorKit . I like this one a lot. Here, after following the tutorial, is my new XML Editor... Unfortunately, though, as I am typing this, a message pops up saying: "This is a non registered JXMLPad Version." And then it tells me to go to the site to register it. Nevertheless, this is what I have now thanks to this cool library:
Most of the functionality is simply configurable, such as this line for coloring:
container.getDocumentColorAccessibility().setColorForTag("text", Color.red);One can also easily add actions, in addition to a standard declarative set. Pity the prices do not correlate with the content of my wallet. Apart from that, really cool.
Two others, smacs.xngr.browser.editor.XMLEditorKit and cz.fimuni.xsrom.text.xml.XMLEditorKit , look interesting, but couldn't find anywhere to download them. They seem to come from universities, are possibly internal projects, and so on. (Maybe the first is an early version of Bounce, since Edwin Dankert seems to be behind both.) Would've liked to have tried them, though!
Note: The NetBeans Platform could also be used in this context, since one can detach the NetBeans IDE XML Editor and use it in one's own application. Plus, there are specific API classes that can extend it further. Here is a thread about opening a file in such an XML Editor and here is a tutorial about extending an XML editor. The benefit of this approach is that one doesn't need to write the editor from scratch. Plus, pluggability means anyone can add to your editor very easily by making additional modules available with new features that can be installed via a Plugin Manager, which is also simply a matter of bundling it up with the editor.
For completion's sake, there's also an XMLEditorKit by Threshold Computer Systems, Inc , although a message dated 01/11/2007 says: "XMLEditorKit 1.0 and sample XMLEditor are temporarily unavailable for download." Note that it is a commercial product. Also, here is the related announcement on Java Ranch, from 2003, describing the full functionality (at that time, anyway).
I've also found one or two references to org.apache.interop.common.ui.xmleditorkit , though only in a mailing list, and it's not clear whether it is still being maintained. Finally, the Xylia Tookit seems to have something available in this area too, although this PDF document about it was written in 2003, so maybe it's no longer with us anymore.
At the end of this overview, I hope to hear from developers who have tried some or all of the above. Plus, there are bound to be some I haven't tracked down. What have your experiences been in this area? Any recommendations?
2 replies so far (
Post your own)
Re: What's the Deal with XMLEditorKit?
I had been using bounce as well . I am not 100% happy with it some times the text scroll to a random(?) position, but it is workable. I set the colors like IE uses it and got a view my users are familiar withRe: What's the Deal with XMLEditorKit?
Hi Geertjan,The kiyut.swing.text.xml.XMLEditorKit package is also have syntax highlight and configurable color schemes. Just override the XMLContext.java to adjust the default xml syntax color highlight. It is just simple a Map (HashMap)
/** Map<String, Color> */ protected Map syntaxForegroundMap = null; /** Map<String, Font> */ protected Map syntaxFontMap = null; eg: syntaxName = XMLContext.ELEMENT_STYLE; font = defaultFont; fontForeground = new Color(0, 0, 255); syntaxFontMap.put(syntaxName, font); syntaxForegroundMap.put(syntaxName, fontForeground);So you can integrate it with your own project preferences / options dialog for configurable syntax highlight
Cheers