Swing GUI Builder and Java Framework using XML
License & Purchase


Hello World

To give a first impression how easy it is to use the framework we write the "Hello World". Instead of just printing out the "Hello World" you will create a frame and put a label in it. First build up a new java project in eclipse or your favorite ide. You need a java file HelloWorld.java and xml file called JEasyRepository.xml. Add the library jeasy.jar to your java build path. Be sure to have the Java SDK 1.5 or higher installed.

Building a GUI

For this small example we don't use the JEasyRepository GUI Designer. Just copy the lines below into your file JEasyRepositoy.xml

<?xml version='1.0' encoding='ISO-8859-1' ?>
		<text>Hello World!</text>
Let us first explain the contents of the xml file. The root tag is always jeasy. Every child will be used to create a jeasy object. Every jeasy object has a unique id that is used to store the object in a hashmap and to reference it to other objects. Most of the jeasy objects are used to build swing components. The first jeasy object is called JEStart and contains some important properties. The startIdApplication defines the father component where all other components will be added. It is always a reference to a JEFrame. The global tag references to a JEGlobal object. Here you may define default fonts, colors, constraints and other properties. They are used, if there is no property defined in the jeasy object. For this small example you don't need to do. The next object is label with the text "Hello World". To see it at the screen the label is added to a frame. Therefore the JEFrame has a tag center that references to your label.

Writing the program

Copy the lines below and paste them into your HelloWorld.java.

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import de.cbse.jeasy.*;
public class HelloWorld {
public static void main(String args[]) { InputStream is = null; try { is = new FileInputStream("JEasyRepository.xml"); } catch (FileNotFoundException e) { e.printStackTrace(); System.exit(-1); } JEUtil.readJEObj(is); JEStart jestart = JEStart.getInstance(); JEFrame frame = (JEFrame)JEUtil.getJO (jestart.getStartIdApplication()); frame.setupComponent(); frame.setVisible(true); } }
To read out the jeasy objects open the file JEasyRepository.xml by creating an InputStream. The method readObj() of the jeasy utilities class JEUtil parses the xml file and will create instances of the jeasy objects. To get the start point for all swing components fetch the JEStart object. Because it is a singleton, get it by getInstance(). Every jeasy object is stored in a hashmap and may be accessed by its jeasy id. This is done by JEUtil.geJO(...). At this point no swing components exist. By setting up the jeasy component by setupComponent() this will be done for the frame and all its children automaticaly. Making the frame visible will pop up the frame. By default the frame window is made a little bit smaller than the screen. Use the width and height properties to change this. Here is the result of your first small JEasy application: