Monday, September 24, 2012

Reusable UI

One of the objectives of this project is to build a reusable test UI, which is not only available for the TPC test, but also for users' self-defined tests.

To achieve this objective, I use properties files of Java.According to the Java API, Properties are configuration values managed as key/value pairs. In each pair, the key and value are both String values. The key identifies, and is used to retrieve, the value, much as a variable name is used to retrieve the variable's value.

I let uses to browse the system and choose the properties files. In each properties file, a property called 'testClassName' is required. The 'testClassName' is the name of the java class which implement the test function. Program searches the default directory to find the java class file and run the test.

Sunday, September 2, 2012

Embed Swing and AWT in SWT

I am looking for a way to draw dynamic diagrams in SWT. I have found a very power Java library called JFreeChart. Unfortunately it support Swing better than SWT. Therefore I need a way to embed Swing into my SWT GUI.

I have discovered that SWT provides an very easy way to do so.For many SWT components, they have a attribute called SWT.EMBEDDED. By adding this attribute, the component knows that another application is plugged in.

Here is an example of this function.

Display display = new display();
Shell shell = new shell(display, SWT.EMBEDDED);
Frame frame = SWT_AWT.new_Frame(shell);
frame.add(new JLabel("This is a Java Swing Label"));