Title: Thinlets
1Thinlets
- GUI Seminar
- Princeton 27/4 2004
- Peter Kriens
2Thinlets
3Thinlets
- 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
4Architecture
Thinlet
5Calculator, XML File
ltpanel gap"4" top"4" left"4"gt lttextfield
name"number1" columns"4" /gt ltlabel text""
/gt lttextfield name"number2" columns"4" /gt
ltbutton text"" action"calculate(number1.text,
number2.text, result)" /gt lttextfield
name"result" editable"false" /gt lt/panelgt
6Calculator, 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)
7Event Handling
- Parse methods
- public Object parse(String path) throws
IOExceptionpublic Object parse(String path,
Object handler) throws IOExceptionpublic Object
parse(InputStream inputstream) throws
IOExceptionpublic Object parse(InputStream
inputstream, Object handler) throws IOException - The widget (in the same XML file) identified by
the given name, its type is Object. - ltbutton action"one" /gt ltlabel name"label1"
text"..." visible"false" /gt ltbutton
action"two(thinlet, this, label1)" /gt - public void one() public void two(Thinlet
thinlet, Object button, Object label) - itemThe component part on which the event
occurred, valid for list item, tree node, table
row, combobox choice, and tabbedpane tab. - this/name/item.attribute
- ltbutton action"three(this.text, this.icon,
label1.visible, label1.colspan)" /gt ltlist
action"four(item, item.text, item.icon)"gt
ltitem text"File" icon"file.gif" /gt lt/listgt - public void three(String buttontext, Image
buttonicon, boolean labelvisible, int labelcols)
public void four(Object item, String itemtext,
Image itemicon)
8Components
- Component
- PopupMenu
- Label
- Button
- CheckBox
- ToggleButton
- ComboBox
- TextField
- PasswordField
- TextArea
- TabbedPane
- Panel
- Desktop
- Dialog
- SpinBox
- ProgressBar
- Slider
- SplitPane
- List
- Table
- Tree
- Separator
- MenuBar
9Showcase
10Theodor, XUL editor
http//www.carlsbadcubes.com/theodore/
11Skinning
http//www.realchat.com/thinlet/
12Layout
- Simple Layout Model
- Based on rows and columns
- Panels are used to define a basic layout
- Min size supported
- Rectangular based
13Coding 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)
14Then Again
- The small size of the total package seems to make
this problem manageable - Would like a single component class though
15Conclusion
- 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