Presentation is loading. Please wait.

Presentation is loading. Please wait.

Thinlets GUI Seminar Princeton 27/4 2004 Peter Kriens.

Similar presentations

Presentation on theme: "Thinlets GUI Seminar Princeton 27/4 2004 Peter Kriens."— Presentation transcript:

1 Thinlets GUI Seminar Princeton 27/ Peter Kriens

2 Thinlets

3 XML Based GUI Based on AWT (Java 1.1) One class! Internationalization Reflection for binding XML to code Recursive Decent set of widgets Extensible Compressed size 38K! GNU Lesser Public License

4 Architecture Thinlet 10,1 Object[] Object[0]Object[1] keyvalue Frame Launcher Applet Launcher YourApp XML handler (through reflection)

5 Calculator, XML File

6 Calculator, Source Code package thinlet.demo; import thinlet.*; public class Calculator extends Thinlet { public Calculator() throws Exception { add(parse("calculator.xml")); } public void calculate(String number1, String number2, Object result) { try { int i1 = Integer.parseInt(number1); int i2 = Integer.parseInt(number2); setString(result, "text", String.valueOf(i1 + i2)); } catch (NumberFormatException nfe) { getToolkit().beep(); } public static void main(String[] args) throws Exception { new FrameLauncher("Calculator", new Calculator(), 320, 240); } action="calculate(number1.text, number2.text, result)"

7 Event Handling Parse methods –public Object parse(String path) throws IOException public Object parse(String path, Object handler) throws IOException public Object parse(InputStream inputstream) throws IOException public Object parse(InputStream inputstream, Object handler) throws IOException The widget (in the same XML file) identified by the given name, its type is Object. – –public void one() {} public void two(Thinlet thinlet, Object button, Object label) {} item The component part on which the event occurred, valid for list item, tree node, table row, combobox choice, and tabbedpane tab. this/name/item.attribute – –public void three(String buttontext, Image buttonicon, boolean labelvisible, int labelcols) {} public void four(Object item, String itemtext, Image itemicon) {}

8 Components Component PopupMenu Label Button CheckBox ToggleButton ComboBox TextField PasswordField TextArea TabbedPane Panel Desktop Dialog SpinBox ProgressBar Slider SplitPane List Table Tree Separator MenuBar

9 Showcase

10 Theodor, XUL editor

11 Skinning

12 Layout Simple Layout Model –Based on rows and columns –Panels are used to define a basic layout –Min size supported Rectangular based

13 Coding Style: No OO Code seems hard to maintain –Large single class –Implements method dispatching in code Performance might be an issue –All methods and fields have to be looked up … if ("spinbox" == classname) { Dimension size = getFieldSize(component); size.width += block; return size; } if ("progressbar" == classname) { boolean horizontal = ("vertical" != get(component, "orientation")); return new Dimension(horizontal ? 76 : 6, horizontal ? 6 : 76); } if ("slider" == classname) { boolean horizontal = ("vertical" != get(component, "orientation")); return new Dimension(horizontal ? 76 : 10, horizontal ? 10 : 76); } if ("splitpane" == classname) { …

14 Then Again The small size of the total package seems to make this problem manageable –Would like a single component class though …

15 Conclusion LGPL might be an issue Not clear how easy it is to do skinning –Skinlet: 09-Sep-03 - Version beta, bugfix release. Minor bugfixes and improvements. I decided to temporarily suspend Skinlet development until it gets clear what the future refactored Thinlet will look like. This is mainly because the current one-class structure makes it really hard to keep up-to- date with each Thinlet update. Rectangular based layout is too restrictive for CE Basic skin is not very nice Performance Hard to extend with new widgets Basic model is very easy to use Thinlets recursive architecture makes it suitable to OSGi GUI editor available Internationalization Small … Checks binding early

Download ppt "Thinlets GUI Seminar Princeton 27/4 2004 Peter Kriens."

Similar presentations

Ads by Google