Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Roll Your Own Swing-based XML Editor (Part I)

Create a custom class that extends JTree to create a visual representation of an XML document.


advertisement
Editor's note: This is the first of a three-part series about how to build your own XML editor.

f you've been looking for a cross-platform, open-source XML editor, you've likely come up short. In the following series of three articles, I will walk you through the development of a simple, no frills, XML editor, utilizing several of the most common Java 2 Swing components. This series will be beneficial to anyone wanting to write their own XML editor, or just to those of you looking to learn or brush up on Swing.

In this first article, we will briefly discuss XML and why a tree structure is appropriate to display XML, and then we will take a look at the JAXP API and how to set up your environment with the necessary XML classes. Then we will learn about the JTree Swing component that displays a graphical tree (a common component in many XML editors). Finally, we will build a reusable class that extends the JTree component that is capable of parsing an XML document and displaying its data in a JTree.



In the second article, we will create the framework for our XML editor. In order to do so, we will cover a variety of Swing components (including JSplitPanes, JScrollPanes, JButtons, and JTextAreas).

In the third and final article, we will add the finishing touches to our editor by building a JMenu component and adding it to the editor. Additionally, we will construct JFileChooser components to access the underlying file system to allow XML documents to be saved and new documents to be opened.



How can I create a visual representation of an XML document?



Create a custom class that extends JTree, capable of parsing an XML file into a DOM object and constructing a JTree from that object.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date