|
This API documentation details the public methods of the Thinlet class.
See the overview
for a simple calculator example.
|
|
|
public Object parse(String path) throws Exception |
public Object parse(InputStream inputstream) throws Exception |
Creates a component (and its subcomponents, and properties)
from the given xml resource or the stream (e.g.
new URL("http://myserver/myservlet").openStream()).
The path is relative to your thinlet package or the classpath
(if the path starts with / character).
public Object find(String name) |
Identify a component object by name inside the desktop or the given
component. Use Object class field to store a component.
public void setString(Object component, String key, String value) |
public void setChoice(Object component, String key, String value) |
public void setBoolean(Object component, String key, boolean value) |
public void setInteger(Object component, String key, int value) |
public void setIcon(Object component, String key, Image icon) |
public void setMethod(Object component, String key, Method method) |
Sets the given property pair (key and value) for the component.
public String getString(Object component, String key) |
public String getChoice(Object component, String key) |
public boolean getBoolean(Object component, String key) |
public int getInteger(Object component, String key) |
public Image getIcon(Object component, String key) |
public Method getMethod(Object component, String key) |
Returns the property value of the given component by the property key.
public Image getIcon(String path) |
public Image getIcon(String path, boolean preload) |
Creates an image, and loads it immediately by default.
The path is relative to your thinlet package or the classpath
(if the path starts with / character).
public Object getDesktop() |
Return the root object.
public Object create(String classname) |
Creates a new component.
public void add(Object component) |
public void add(Object parent, Object component) |
public void add(Object parent, Object component, int index) |
Adds the specified component to the topmost position on the desktop. Or
add it to the parent component (at the specified index).
The following example fills a table with system property key and value pairs,
the table (in an xml file) named mytable and has two columns
(titled Keys and Values):
Object table = find("mytable");
Properties sp = System.getProperties();
for (Enumeration keys = sp.keys(); keys.hasMoreElements();) {
String key = (String) keys.nextElement();
Object row = create("row");
Object keycell = create("cell");
setString(keycell, "text", key);
add(row, keycell);
Object valuecell = create("cell");
setString(valuecell, "text", sp.getProperty(key));
add(row, valuecell);
add(table, row);
} |
public void remove(Object component) |
Removes the specified component from its parent.
public void removeAll(Object component) |
public void removeAll(Object component, String key) |
Removes all children of the component (the default list or the specified).
public int getCount(Object component) |
public int getCount(Object component, String key) |
Returns the count of subcomponents in the list of the given
component. The list is identified by the key name for tabbed pane
(tab, or component) or table
(column, or row) The component and the row
is the default key.
public int getSelectedIndex(Object component) |
Returns the index of the first selected item, node, or row in
the given list, tree, or table. Rerturns -1 if no selected item.
public Object getItem(Object component, int index) |
public Object getItem(Object component, String key, int index) |
Returns the subcomponent in the given component at the specified index.
The following code lists the selected items of a list component
named mylist:
Object list = find("mylist");
int n = getCount(list);
for (int i = 0; i < n; i++) {
Object item = getItem(list, i);
if (getBoolean(item, "selected")) {
System.out.println(getString(item, "text"));
}
} |
public boolean requestFocus(Object component) |
Focus the given component (and the Thinlet component).
public void setColors(int background, int text, int textbackground, int border, int disable, int hover, int press, int focus, int select) |
public void setFont(Font font) |
To customize the look and feel set the used 9 colors and the font.
The scrollbars', spinbox arrows', etc. size is depends on the font size.
protected void parseXML(InputStream inputstream) throws Exception |
protected void startElement(String name, Hashtable attributelist) |
protected void characters(String text) |
protected void endElement() |
Parses the given resource and calls the methods, you can overwrite these.
|