Browse DevX
Sign up for e-mail newsletters from DevX


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

Learn how to manipulate JFrame objects to create an XML text editor that has a text view and a graphical view and that updates the graphical view based upon changes you make to the text.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Editor's note: This is the second 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 this three-part series of 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.

This is the second article in the series. In the first article, we briefly discussed XML and why a tree structure is appropriate to display XML, how to handle XML data, how to work with the JTree Swing component, and we built a reusable component that is capable of parsing an XML document and displaying its data in a JTree.

In this article, we will create the framework for our XML editor. In order to do so, we will cover a variety of Swing components (including JSplitPane, JScrollPane, JButton, and JTextArea).

How can I create an XML text editor that has a text view and a graphical view, and updates the graphical view based upon changes I make to the text?

Create a JFrame object that contains a JButton and a JSplitPane. Then have the JSplitPane contain two JScrollPanes. One will house the graphical view (the xTree class) and the other will house the textual view (a JTextArea). The JButton will manage the graphical view refresh.

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