Download presentation
Presentation is loading. Please wait.
Published byJordan Barnes Modified over 11 years ago
1
Thinlets GUI Seminar Princeton 27/4 2004 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 http://www.carlsbadcubes.com/theodore/
11
Skinning http://www.realchat.com/thinlet/
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 0.4.2 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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.