Using Jaxe within another application
Jaxe's startup class is (unsurprisingly) jaxe.Jaxe. This class gathers external events handling (file opening, closing, etc...), so it can be useful to take a look at it to see how a new Jaxe document is created or opened.
Another important class is jaxe.JaxeFrame. This class relates to an XML document window. It is using the class jaxe.JaxeMenuBar to handle the menubar, this one being unfortunately (because of a shortcoming of Java) linked to the window.
The easiest way to include Jaxe in another application is probably to use the class jaxe.JaxeTextPane, which represents the text area in the XML window. Since this class is derived from java.swing.JTextPane, it can easily be added wherever required, according to the host application layout. The constructor requires a JaxeDocument (linked to the DOM) and a JFrame (the parent window).
The object of class jaxe.JaxeDocument has to be initialised with a Jaxe configuration file (handled by the class jaxe.Config) and possibly with an XML file or with a DOM object.
To sum up, here is a list of instructions to include a Jaxe text area in a parent Container located in a given frame:
JaxeDocument jaxeDoc = new JaxeDocument("mylanguage_config.xml"); JaxeTextPane jaxeTextPane = new JaxeTextPane(jaxeDoc, frame); jaxeDoc.lire(xmlFileURL); // or jaxeDoc.setDOMDoc(domDocument); parent.add(jaxeTextPane);
Elements can be inserted with the contextual menu, or with jaxe.ActionInsertionBalise actions. The constructor for ActionInsertionBalise requires the Jaxe document, and the DOM element corresponding to the definition of the element in the Jaxe configuration file.
The document can later be saved with the method JaxeDocument.ecrire(File f).