public class Thinlet extends Container implements Runnable, Serializable
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
Thinlet() |
Modifier and Type | Method and Description |
---|---|
void |
add(Object component)
Adds the specified component to the root desktop
|
void |
add(Object parent,
Object component)
Adds the specified component to the end of the specified container
|
void |
add(Object parent,
Object component,
int index)
Adds the specified component to the container at the given position
|
protected void |
characters(String text)
The SAX-like parser calls this method, you have to overwrite it
|
Object |
create(String classname)
Creates a new component
|
boolean |
destroy()
This method is called by the FrameLauncher if the window was closing,
or AppletLauncher's destroy method.
|
protected void |
endElement()
The SAX-like parser calls this method, you have to overwrite it
|
Object |
find(Object component,
String name)
Finds the first component from the specified component by a name
|
Object |
find(String name)
Finds the first component from the root desktop by a specified name value
|
boolean |
getBoolean(Object component,
String key)
Gets the property value of the given component by the property key
|
String |
getChoice(Object component,
String key)
Gets the property value of the given component by the property key
|
String |
getClass(Object component)
Gets the type of the given component
|
int |
getCount(Object component)
Gets the count of subcomponents in the list of the given component
|
int |
getCount(Object component,
String key)
Gets the count of subcomponents in the list of the given component
|
Object |
getDesktop()
Get the topmost component
|
protected String |
getDOMAttribute(Object node,
String key)
Gets the attribute value by the specified key for a DOM tag
|
protected int |
getDOMCount(Object node,
String key)
Gets the number of tags in a tag by a specified tagname
|
protected Object |
getDOMNode(Object node,
String key,
int index)
Gets the subtag of the specified tag by tagname and index
|
protected String |
getDOMText(Object node)
Gets the content string of a tag
|
Image |
getIcon(Object component,
String key)
Gets the property value of the given component by the property key
|
Image |
getIcon(String path)
Creates an image, and loads it immediately by default
|
Image |
getIcon(String path,
boolean preload)
Creates an image from the specified resource.
|
int |
getInteger(Object component,
String key)
Gets the property value of the given component by the property key
|
Object |
getItem(Object component,
int index)
Returns the subcomponent of the given component at the specified index
|
Object |
getItem(Object component,
String key,
int index)
Returns the subcomponent of the given component's specified list at the given index
|
Object[] |
getItems(Object component)
Gets all the components in this container
|
Object[] |
getItems(Object component,
String key)
Gets all the components in this container's specified list
|
Object |
getParent(Object component)
Gets the parent of this component
|
Dimension |
getPreferredSize()
Gets the preferred size of the root component
|
Object |
getProperty(Object component,
Object key)
Returns the value of the property with the specified key.
|
int |
getSelectedIndex(Object component)
Gets the index of the first selected item in the given component (list, table, or tree)
|
Object |
getSelectedItem(Object component)
Gets the first selected item of the given component (list, table, or tree)
|
Object[] |
getSelectedItems(Object component)
Gets the selected item of the given component (list, table, or tree)
when multiple selection is allowed
|
String |
getString(Object component,
String key)
Gets the property value of the given component by the property key
|
boolean |
isFocusTraversable()
This component can be traversed using Tab or Shift-Tab keyboard focus traversal,
although 1.4 replaced this method by isFocusable,
so 1.4 compilers write deprecation warning
|
void |
paint(Graphics g)
Paints the components inside the graphics clip area
|
Object |
parse(InputStream inputstream)
Creates a component from the given stream
|
Object |
parse(InputStream inputstream,
Object handler)
Creates a component from the given stream and event handler
|
Object |
parse(String path)
Creates a component (and its subcomponents, and properties)
from the given xml resource
|
Object |
parse(String path,
Object handler)
Creates a component from the given xml resource using the
specified event handler
|
protected Object |
parseDOM(InputStream inputstream)
You can use the internal xml parser as a simple DOM-like parser,
use the getDOMAttribute, getDOMText,
getDOMCount, getDOMNode, getClass,
and getParent methods to analise the document
|
protected void |
parseXML(InputStream inputstream)
You can use the internal xml parser as a simple SAX-like parser,
during the process it calls the startElement, characters,
and endElement methods
|
protected void |
processEvent(AWTEvent e)
Dispatches mouse, key, focus, and component events occurring on the
Thinlet component internally
|
void |
putProperty(Object component,
Object key,
Object value)
Binds the specified key to the specified value, and stores in this component.
|
void |
remove(Object component)
Removes the specified component from its parent
|
void |
removeAll(Object component)
Removes all the components from this container
|
void |
removeAll(Object component,
String key)
Removes all the components from this container's specified list
|
boolean |
requestFocus(Object component)
Requests that both the Thinlet component,
and the given widget get the input focus
|
void |
run()
A second thread is used to repeat value change events for scrollbar or spinbox
during the mouse is pressed, or to pop up tooltip
|
void |
setBoolean(Object component,
String key,
boolean value)
Sets the given property pair (key and value) for the component
|
void |
setChoice(Object component,
String key,
String value)
Sets the given property pair (key and value) for the component
|
void |
setColors(int background,
int text,
int textbackground,
int border,
int disable,
int hover,
int press,
int focus,
int select)
Sets the 9 colors used for components, and repaints the whole UI
|
void |
setFont(Font font)
Sets the only one font used everywhere, and revalidates the whole UI.
|
void |
setIcon(Object component,
String key,
Image icon)
Sets the given property pair (key and value) for the component
|
void |
setInteger(Object component,
String key,
int value)
Sets the given property pair (key and value) for the component
|
void |
setMethod(Object component,
String key,
String value,
Object root,
Object handler)
Sets a new event handler method for a component
|
void |
setString(Object component,
String key,
String value)
Sets the given property pair (key and value) for the component
|
protected void |
startElement(String name,
Hashtable attributelist)
The SAX-like parser calls this method, you have to overwrite it
|
void |
update(Graphics g)
Invokes the paint method
|
add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, isValidateRoot, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public void setColors(int background, int text, int textbackground, int border, int disable, int hover, int press, int focus, int select)
background
- the backround of panels (dialogs, desktops),
and disabled controls, not editable texts, lines between list items
(the default value if #e6e6e6)text
- for text, arrow foreground (black by default)textbackground
- the background of text components, and lists
(white by default)border
- for outer in inner borders of enabled components
(#909090 by default)disable
- for text, border, arrow color in disabled components
(#b0b0b0 by default)hover
- indicates that the mouse is inside a button area
(#ededed by default)press
- for pressed buttons,
gradient image is calculated using the background and this press color
(#b9b9b9 by default)focus
- for text caret and rectagle color marking the focus owner
(#89899a by default)select
- used as the background of selected text, and list items,
and in slider (#c5c5dd by default)public void setFont(Font font)
public Dimension getPreferredSize()
getPreferredSize
in class Container
public void paint(Graphics g)
public void run()
public boolean isFocusTraversable()
isFocusTraversable
in class Component
protected void processEvent(AWTEvent e)
processEvent
in class Container
public boolean requestFocus(Object component)
component
- a focusable widget inside
visible and enabled parents, and tabbedpane's selected tabpublic Object create(String classname)
classname
- the widget type (e.g. button)IllegalArgumentException
- for unknown widget typepublic String getClass(Object component)
component
- a widgetpublic Object getDesktop()
public int getCount(Object component)
component
- a widgetpublic int getCount(Object component, String key)
component
- a widgetkey
- 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 keypublic Object getParent(Object component)
component
- a widgetpublic int getSelectedIndex(Object component)
component
- a widgetpublic Object getSelectedItem(Object component)
component
- a widgetpublic Object[] getSelectedItems(Object component)
component
- a widgetpublic void removeAll(Object component)
component
- the specified containerpublic void removeAll(Object component, String key)
component
- the specified containerkey
- 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 keypublic Object getItem(Object component, int index)
component
- a specified containerindex
- the index of the component to getpublic Object[] getItems(Object component)
component
- a specified containerpublic Object getItem(Object component, String key, int index)
component
- a specified containerkey
- the list is identified by the key nameindex
- the index of the component to getpublic Object[] getItems(Object component, String key)
component
- a specified containerkey
- the list is identified by the key namepublic void add(Object component)
component
- a widget to be addedpublic void add(Object parent, Object component)
parent
- a containercomponent
- a component to be addedpublic void add(Object parent, Object component, int index)
parent
- a containercomponent
- a component to be insertedindex
- the position at which to insert the component,
or -1 to insert the component at the endpublic void remove(Object component)
component
- the component to be removedIllegalArgumentException
public Object find(String name)
name
- parameter value identifies the widgetpublic Object find(Object component, String name)
component
- the widget is searched inside this componentname
- parameter value identifies the widgetpublic void putProperty(Object component, Object key, Object value)
component
- the hashtable is binded to this componentkey
- the client property keyvalue
- the new client property valuepublic Object getProperty(Object component, Object key)
component
- searches the hashtable of this componentkey
- the client property keypublic Object parse(String path) throws IOException
path
- is relative to your thinlet instance or the classpath
(if the path starts with an / character)IOException
public Object parse(String path, Object handler) throws IOException
path
- is relative to your application package or the classpathhandler
- bussiness methods are implemented in this objectIOException
public Object parse(InputStream inputstream) throws IOException
inputstream
- e.g. new URL("http://myserver/myservlet").openStream()IOException
public Object parse(InputStream inputstream, Object handler) throws IOException
inputstream
- read xml from this streamhandler
- event handlers are implemented in this objectIOException
protected void parseXML(InputStream inputstream) throws IOException
inputstream
- e.g. new URL("http://myserver/myservlet").openStream()IOException
protected void startElement(String name, Hashtable attributelist)
name
- of the tagattributelist
- a list of attributes including keys and value pairsprotected void characters(String text)
text
- the content of a tagprotected void endElement()
protected Object parseDOM(InputStream inputstream) throws IOException
inputstream
- e.g. new URL("http://myserver/myservlet").openStream()IOException
protected String getDOMAttribute(Object node, String key)
node
- a specified tagkey
- a string to identify the value pairprotected String getDOMText(Object node)
node
- a specified tagprotected int getDOMCount(Object node, String key)
node
- a specified tagkey
- the searched tagnameprotected Object getDOMNode(Object node, String key, int index)
node
- a specified tagkey
- the searched tagnameindex
- the index of the requested subtagpublic void setString(Object component, String key, String value)
public String getString(Object component, String key)
public void setChoice(Object component, String key, String value)
public String getChoice(Object component, String key)
public void setBoolean(Object component, String key, boolean value)
public boolean getBoolean(Object component, String key)
public void setInteger(Object component, String key, int value)
public int getInteger(Object component, String key)
public void setIcon(Object component, String key, Image icon)
public Image getIcon(Object component, String key)
public void setMethod(Object component, String key, String value, Object root, Object handler)
component
- the target componentkey
- the key name of the parameter (e.g. action)value
- the method name and parameters
(e.g. foo(this, this.text, mybutton, mybutton.enabled)
for public void foo(Object component, String text, Object mybutton, boolean enabled))root
- the search starting component for name components in the argumentshandler
- the target event handler object including the methodIllegalArgumentException
public Image getIcon(String path)
path
- is relative to your thinlet instance or the classpath
(if the path starts with '/' character)public Image getIcon(String path, boolean preload)
path
- is relative to your thinlet instance or the classpathpreload
- waits for the whole image if true, starts loading
(and repaints, and updates the layout) only when required (painted, or size requested) if falsepublic boolean destroy()
Copyright © 2015. All rights reserved.