Properties
The property types are as follows: string, choice, boolean, integer, icon,
method, component, property, font, color, keystroke, and bean. This page
summarizes the possible attribute values in the XML resources, and the
corresponding setter/getter methods in the Thinlet
class.
string
String value is a simple text, although you can use the following entities for
the XML attribute values:
<
for less than, >
for greater than,
&
for ampersand, "
for quotation mark,
'
for apostrophe, and
&x??;
including the hexadecimal or
&??;
the decimal code of the character.
E.g. use the ©
decimal code for the copyright mark
instead of the ©
named entity.
public void setString(Object component, String key, String value)
public String getString(Object component, String key)
choice
Unlike string, the choice parameter's possible values are limited,
e.g. only the left, center, and right values
are legal for content alignment in a label.
public void setChoice(Object component, String key, String value)
public String getChoice(Object component, String key)
boolean
Lower case true
and false
values are expected.
public void setBoolean(Object component, String key, boolean value)
public boolean getBoolean(Object component, String key)
integer
A signed decimal integer.
public void setInteger(Object component, String key, int value)
public int getInteger(Object component, String key)
icon
The image is specified by the path, the path is relative to your thinlet
instance, or the classpath (if the it starts with '/' character),
or a full URL. E.g. from your mycompany.myapp.MyThinlet
thinlet
instance the mypackage/images/logo.gif
is available as
../images/logo.gif
, or /mypackage/images/logo.gif
,
even with the valid http://mycompany/img/logo.gif
URL.
public void setIcon(Object component, String key, Image icon)
public Image getIcon(Object component, String key)
Use the following methods to create an image from the specified
resource (a relative, or an absolute path, or an URL):
public Image getIcon(String path)
public Image getIcon(String path, boolean preload)
method
See the event handling page for more details.
public void setMethod(Object component, String key, String value, Object root, Object handler)
component
Component is a thinlet widget specified by its name, currently
used only for label's for attribute.
property
The format of its value is key=value
, both are stored in a
hashtable of the component as strings. Use the ';' separator
for multiple properties, e.g. key1=1st value;key2=value2
.
Unfortunately you can't use the separator character (or as ;
entity) in a property value.
public void putProperty(Object component, Object key, Object value)
public Object getProperty(Object component, Object key)
font
The font string may contains bold, or italic strings for style,
integer for the size, and the remainings specifies the name. These tokens are
separated by whitespaces. At least one font parameter must be present.
The undefined name, style, or size is specified by
thinlet's present font. E.g. the bold 14 italic
value defines
the new Font('SansSerif', Font.BOLD + Font.ITALIC, 14)
(if the default font was SansSerif plain 12).
public void setFont(Object component, String key, Font font)
public Font getFont(Object component, String key)
color
Color value is defined by a string that represents a color as hexidecimal
numbers starting with #
, or 0x
and including the
RGB values in hexadecimal format as RRGGBB. Or
RGB values as integers separated by commas or whitespaces, e.g both
#ff0000
, 0xff0000
, and
255, 0, 0
are red.
public void setColor(Object component, String key, Color color)
public Color getColor(Object component, String key)
keystroke
The keystroke contains modifiers (defined in
java.awt.event.InputEvent
as modifier name + '_MASK')
and a key (defined in
java.awt.event.KeyEvent
as 'VK_' + key name).
E.g. ctrl+alt escape
means InputEvent.CTRL_MASK |
InputEvent.ALT_MASK
, and KeyEvent.VK_ESCAPE
.
The tokens are separated by '+' or whitespaces.
public void setKeystroke(Object component, String key, String value)
bean
Note: this widget is very limited, e.g. you can use
it for a chart (see the chart draft example for more details), but it won't
receive events, and can't use Component's repaint
or requestFocus
method. It's nonsense
to include a Swing component in the future, it requires the Swing environment
including its repaint manager, popup factory, and focus manager.
The java.awt.Component
is associated with the class name.
Currently used only for the bean widget.
public void setComponent(Object component, String key, Component bean)
public Component getComponent(Object component, String key)