thinwire.ui
Class Frame

java.lang.Object
  extended by thinwire.ui.Frame
All Implemented Interfaces:
Component, Container<Component>, ItemChangeEventComponent, Window

public final class Frame
extends java.lang.Object

A Frame is the browser window. It is created by the Application instance and automatically toggled to visible. When visible is set to false, the session is closed.

Example:

 Frame frm = Application.current().getFrame();
 frm.setTitle("Frame Test");
 
 for (int i = 0; i < 5; i++) {
        Dialog dlg = new Dialog();
        dlg.setBounds((i * 100) + 10, 10, 90, 300);
        dlg.setTitle("Dlg-" + (i + 1) + "-" + dlg.getX() + "-" + dlg.getY());
        Label lb = new Label("#" + (i + 1));
        lb.setBounds(10, 10, 50, 30);
        dlg.getChildren().add(lb);
        frm.getChildren().add(dlg);
 }
 
 


Nested Class Summary
 
Nested classes/interfaces inherited from interface thinwire.ui.Container
Container.ScrollType
 
Field Summary
 
Fields inherited from interface thinwire.ui.Window
PROPERTY_MENU, PROPERTY_TITLE
 
Fields inherited from interface thinwire.ui.Container
PROPERTY_LAYOUT, PROPERTY_SCROLL_TYPE
 
Fields inherited from interface thinwire.ui.Component
ACTION_CLICK, ACTION_DOUBLE_CLICK, PROPERTY_ENABLED, PROPERTY_FOCUS, PROPERTY_FOCUS_CAPABLE, PROPERTY_HEIGHT, PROPERTY_LIMIT, PROPERTY_USER_OBJECT, PROPERTY_VISIBLE, PROPERTY_WIDTH, PROPERTY_X, PROPERTY_Y
 
Method Summary
 void addActionListener(java.lang.String[] actions, ActionListener listener)
          Adds a ActionListener to this component that will be notified when any of the specified actions occur.
 void addActionListener(java.lang.String action, ActionListener listener)
          Adds a ActionListener to this component that will be notified when the specified action occurs.
 void addDropListener(Component[] dragComponents, DropListener listener)
           
 void addDropListener(Component dragComponent, DropListener listener)
           
 void addItemChangeListener(ItemChangeListener listener)
          Adds a listener which executes a method when something is changed.
 void addKeyPressListener(java.lang.String[] keyPressCombos, KeyPressListener listener)
          Adds a KeyPressListener that will be notified when any of the specified key press combinations occur.
 void addKeyPressListener(java.lang.String keyPressCombo, KeyPressListener listener)
          Adds a KeyPressListener that will be notified when the specified key press combination occurs.
 void addPropertyChangeListener(java.lang.String[] propertyNames, PropertyChangeListener listener)
          Adds a PropertyChangeListener to this component that will be notified when any of the specified properties change.
 void addPropertyChangeListener(java.lang.String propertyName, PropertyChangeListener listener)
          Adds a PropertyChangeListener to this componetn that will be notified when the specified property changes.
 void fireAction(ActionEvent ev)
          Programmatically signals an action which triggers the appropriate listener which calls the desired method.
 void fireAction(java.lang.String action)
          A convenience method that is equal to this.fireAction(new ActionEvent(this, action));
 void fireAction(java.lang.String action, java.lang.Object source)
          A convenience method that is equal to this.fireAction(new ActionEvent(this, action));
 void fireDrop(Component dragComponent)
           
 void fireDrop(Component dragComponent, java.lang.Object dragObject)
           
 void fireDrop(DropEvent ev)
           
 void fireKeyPress(KeyPressEvent ev)
          Allows you to programmatically trigger a key press combination.
 void fireKeyPress(java.lang.String keyPressCombo)
          A convenience method that is equal to this.fireKeyPress(new KeyPressEvent(keyPressCombo, this));
protected  boolean firePropertyChange(java.lang.Object source, java.lang.String propertyName, boolean oldValue, boolean newValue)
           
protected  boolean firePropertyChange(java.lang.Object source, java.lang.String propertyName, int oldValue, int newValue)
           
protected  boolean firePropertyChange(java.lang.Object source, java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
           
 java.util.List<T> getChildren()
          Returns a list of components in the container.
 T getChildWithFocus()
          Get the child Component for this container that currently has the focus.
 T getComponentWithFocus()
          Get the Component at the bottom of the component hiearchy that has the focus.
 Container getContainer()
          Returns the parent Container of this Component.
 java.util.List<Dialog> getDialogs()
          Returns a read-only list of all visible child dialogs.
 int getHeight()
          Returns the height of this Component.
 int getInnerHeight()
          Returns the usable inner height of the Container.
 int getInnerWidth()
          Returns the usable inner width of the Container.
 Label getLabel()
          Returns the Label assigned to this Component.
 Layout getLayout()
          Gets the current layout manager that is responsible for sizing and positioning components of this Container.
 java.lang.Object getLimit()
          Gets the layout limit that controls the bounds of this component within the context of the parent Container's layout.
 Menu getMenu()
          Gets the main menubar for the window.
 java.lang.Object getParent()
          Returns the parent Object of this Component.
 Container.ScrollType getScrollType()
          Gets the current scrollType defined for the Container.
 Style getStyle()
          Returns a Style object representing this Component's current style settings.
 java.lang.String getTitle()
          Gets the title of the window.
 java.lang.Object getUserObject()
          Returns the user defined Object for this Component.
 int getWidth()
          Returns the width of this Component.
 int getX()
          Returns the X coordinate of this Component.
 int getY()
          Returns the Y coordinate of this Component.
 boolean isEnabled()
          Returns whether this Component is enabled and therefore supports user interaction.
 boolean isFocus()
          Returns whether this Component has the input focus.
 boolean isFocusCapable()
          Returns whether this Component supports gaining focus.
 boolean isVisible()
          Returns a boolean value indicating whether this Component may be displayed in a window.
 void removeActionListener(ActionListener listener)
          Unregister an ActionListener from all action event notifications from this component.
 void removeDropListener(DropListener listener)
           
 void removeItemChangeListener(ItemChangeListener listener)
          Removes an existing itemChangeListener.
 void removeKeyPressListener(KeyPressListener listener)
          Removes the specified KeyPressListener from the component.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes the specified PropertyChangeListener from the component.
 Component setBounds(int x, int y, int width, int height)
          Assigns the specified width, height, X and Y values to this Component atomically, in one operation.
 void setEnabled(boolean enabled)
          Assigns whether this Component is enabled and therefore supports user interaction.
 void setFocus(boolean focus)
          Assigns whether this Component has the input focus.
 void setFocusCapable(boolean focusCapable)
          Assigns whether this Component supports gaining focus.
 void setHeight(int height)
          Assigns the specified height to this Component.
Default: 0
Events:
 void setLayout(Layout layout)
          Sets the layout manager that is used to size and position components of this Container.
 Component setLimit(java.lang.Object limit)
          Sets a layout limit that controls the bounds of this component within the context of the parent Container's layout.
 void setMenu(Menu menu)
          Sets the main menubar for the window.
 Component setPosition(int x, int y)
          Assigns the specified X and Y coordinates to this Component atomically, in one operation.
 void setScrollType(Container.ScrollType scrollType)
          Sets the scrollType for the X and Y axis of this Container.
 Component setSize(int width, int height)
          Assigns the specified width and height to this Component atomically, in one operation.
 void setTitle(java.lang.String title)
          Sets the title of the window.
 void setUserObject(java.lang.Object userObject)
          Assigns a user defined Object to this Component.
 void setVisible(boolean visible)
          Although tecnhically visible is false for a Window by default, the Application instance automatically sets visible to true when the app is started.
 void setWidth(int width)
          Assigns the specified width to this Component.
Default: 0
Events:
 void setX(int x)
          Assigns the specified X coordinate to this Component.
Default: 0 Events:
 void setY(int y)
          Assigns the specified Y coordinate to this Component.
Default: 0 Events:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface thinwire.ui.Container
getChildren, getChildWithFocus, getComponentWithFocus, getLayout, getScrollType, setLayout, setScrollType
 
Methods inherited from interface thinwire.ui.ItemChangeEventComponent
addItemChangeListener, removeItemChangeListener
 
Methods inherited from interface thinwire.ui.Component
addActionListener, addActionListener, addDropListener, addDropListener, addKeyPressListener, addKeyPressListener, addPropertyChangeListener, addPropertyChangeListener, fireAction, fireAction, fireAction, fireDrop, fireDrop, fireDrop, fireKeyPress, fireKeyPress, getContainer, getHeight, getLabel, getLimit, getParent, getStyle, getUserObject, getWidth, isEnabled, isFocus, isFocusCapable, isVisible, removeActionListener, removeDropListener, removeKeyPressListener, removePropertyChangeListener, setBounds, setEnabled, setFocus, setFocusCapable, setLimit, setPosition, setSize, setUserObject
 

Method Detail

getDialogs

public java.util.List<Dialog> getDialogs()
Returns a read-only list of all visible child dialogs.

Returns:
A read-only list of all visible child dialogs.

getInnerWidth

public int getInnerWidth()
Description copied from interface: Container
Returns the usable inner width of the Container.

Specified by:
getInnerWidth in interface Container<Component>
Returns:
the usable inner width of the Container.

getInnerHeight

public int getInnerHeight()
Description copied from interface: Container
Returns the usable inner height of the Container.

Specified by:
getInnerHeight in interface Container<Component>
Returns:
the usable inner height of the Container.

getX

public int getX()
Description copied from interface: Component
Returns the X coordinate of this Component.

Specified by:
getX in interface Component
Returns:
the X coordinate (in pixels) of this Component
Throws:
java.lang.UnsupportedOperationException
See Also:
Component.setX(int)

setX

public void setX(int x)
Description copied from interface: Component
Assigns the specified X coordinate to this Component.
Default: 0 Events:

If the prior value and new value differ, setting this property causes a PropertyChangeEvent ( propertyName = PROPERTY_X ) to be generated.

Specified by:
setX in interface Component
Parameters:
x - the x coordinate (in pixels) to assign to this Component
Throws:
java.lang.UnsupportedOperationException
See Also:
Component.getX(), Component.setPosition(int, int), Component.setBounds(int, int, int, int), Component.PROPERTY_X, PropertyChangeEvent

getY

public int getY()
Description copied from interface: Component
Returns the Y coordinate of this Component.

Specified by:
getY in interface Component
Returns:
the Y coordinate (in pixels) of this Component
Throws:
java.lang.UnsupportedOperationException
See Also:
Component.setY(int)

setY

public void setY(int y)
Description copied from interface: Component
Assigns the specified Y coordinate to this Component.
Default: 0 Events:

If the prior value and new value differ, setting this property causes a PropertyChangeEvent ( propertyName = PROPERTY_Y ) to be generated.

Specified by:
setY in interface Component
Parameters:
y - the y coordinate (in pixels) to assign to this Component
Throws:
java.lang.UnsupportedOperationException
See Also:
Component.getY(), Component.setPosition(int, int), Component.setBounds(int, int, int, int), Component.PROPERTY_Y, PropertyChangeEvent

setWidth

public void setWidth(int width)
Description copied from interface: Component
Assigns the specified width to this Component.
Default: 0
Events:

If the prior value and new value differ, setting this property causes a PropertyChangeEvent ( propertyName = PROPERTY_WIDTH ) to be generated.

Specified by:
setWidth in interface Component
Parameters:
width - the width (in pixels) to assign to this Component
Throws:
java.lang.UnsupportedOperationException
See Also:
Component.getWidth(), Component.setSize(int, int), Component.setBounds(int, int, int, int), Component.PROPERTY_WIDTH, PropertyChangeEvent

setHeight

public void setHeight(int height)
Description copied from interface: Component
Assigns the specified height to this Component.
Default: 0
Events:

If the prior value and new value differ, setting this property causes a PropertyChangeEvent ( propertyName = PROPERTY_HEIGHT ) to be generated.

Specified by:
setHeight in interface Component
Parameters:
height - the height (in pixels) to assign to this Component
Throws:
java.lang.UnsupportedOperationException
See Also:
Component.getHeight(), Component.setSize(int, int), Component.setBounds(int, int, int, int), Component.PROPERTY_HEIGHT, PropertyChangeEvent

setVisible

public void setVisible(boolean visible)
Although tecnhically visible is false for a Window by default, the Application instance automatically sets visible to true when the app is started. Setting visible to false will cause the app instance to close and terminate the session.

Specified by:
setVisible in interface Component
Parameters:
visible - true to indicate this Component may be displayed, false otherwise
See Also:
Component.setVisible(boolean)

getTitle

public java.lang.String getTitle()
Description copied from interface: Window
Gets the title of the window.

Specified by:
getTitle in interface Window
Returns:
the title of the window.

setTitle

public void setTitle(java.lang.String title)
Description copied from interface: Window
Sets the title of the window.

Specified by:
setTitle in interface Window

getMenu

public Menu getMenu()
Description copied from interface: Window
Gets the main menubar for the window.

Specified by:
getMenu in interface Window
Returns:
the main menubar for the window.

setMenu

public void setMenu(Menu menu)
Description copied from interface: Window
Sets the main menubar for the window. If null, there will be no menubar.

Specified by:
setMenu in interface Window

getScrollType

public Container.ScrollType getScrollType()
Description copied from interface: Container
Gets the current scrollType defined for the Container.

Specified by:
getScrollType in interface Container<T extends Component>
Returns:
the current scrollType defined for the Container.

setScrollType

public void setScrollType(Container.ScrollType scrollType)
Description copied from interface: Container
Sets the scrollType for the X and Y axis of this Container. By default the scroll type is ScrollType.NONE.

Specified by:
setScrollType in interface Container<T extends Component>
Parameters:
scrollType - one of the enum ScrollType constants.
See Also:
#PROPERTY_SCROLL, PropertyChangeEvent

getLayout

public Layout getLayout()
Description copied from interface: Container
Gets the current layout manager that is responsible for sizing and positioning components of this Container.

Specified by:
getLayout in interface Container<T extends Component>
Returns:
the Layout implementation used by this Container.
See Also:
Container.setLayout(Layout), Component.getLimit(), Component.setLimit(Object), Layout

setLayout

public void setLayout(Layout layout)
Description copied from interface: Container
Sets the layout manager that is used to size and position components of this Container. If a Layout is not specified for a container, then you must size and position of the components within a container manually. Default: null (i.e. fixed absolute coordinate positioning)

Specified by:
setLayout in interface Container<T extends Component>
Parameters:
layout - any class implementing the Layout interface, or null.
See Also:
Container.PROPERTY_LAYOUT, Component.getLimit(), Component.setLimit(Object), Layout, PropertyChangeEvent

addItemChangeListener

public void addItemChangeListener(ItemChangeListener listener)
Description copied from interface: ItemChangeEventComponent
Adds a listener which executes a method when something is changed.

Specified by:
addItemChangeListener in interface ItemChangeEventComponent
Parameters:
listener - the listener to add

removeItemChangeListener

public void removeItemChangeListener(ItemChangeListener listener)
Description copied from interface: ItemChangeEventComponent
Removes an existing itemChangeListener.

Specified by:
removeItemChangeListener in interface ItemChangeEventComponent
Parameters:
listener - the listener to remove

getChildren

public java.util.List<T> getChildren()
Description copied from interface: Container
Returns a list of components in the container.

Specified by:
getChildren in interface Container<T extends Component>
Returns:
this Container's children.

getChildWithFocus

public T getChildWithFocus()
Description copied from interface: Container
Get the child Component for this container that currently has the focus. If this container contains another container and that container contains the Component at the bottom of the component hiearchy with the focus, this method will return the Container contained by this container, not the Component. If you want the component at the bottom of the component hiearchy that has the focus, use getComponentWithFocus().

Specified by:
getChildWithFocus in interface Container<T extends Component>
Returns:
the child Component with focus, or null if there is no child with focus.

getComponentWithFocus

public T getComponentWithFocus()
Description copied from interface: Container
Get the Component at the bottom of the component hiearchy that has the focus. This method first walks up the component hiearchy to find the root Container, then it walks down the hiearchy to locate the component at the bottom of the component hiearchy that has the focus.

Specified by:
getComponentWithFocus in interface Container<T extends Component>
Returns:
the Component at the bottom of component hiearchy that has the focus, or null if no component does.

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      PropertyChangeListener listener)
Description copied from interface: Component
Adds a PropertyChangeListener to this componetn that will be notified when the specified property changes. Adding a property listener to a component allows your code to react to a state change within the component.
Example:
 final TextField tf = new TextField();
 tf.setEnabled(false);
 
 CheckBox cb = new CheckBox("Check me to enable the TextField.");
 cb.addPropertyChangeListener(CheckBox.PROPERTY_CHECKED, new PropertyChangeListener() {
     public void propertyChange(PropertyChangeEvent pce) {
         if (pce.getNewValue() == Boolean.TRUE) {
             tf.setEnabled(true);
         } else {
             tf.setEnabled(false);
         }
     }
 });
 

Specified by:
addPropertyChangeListener in interface Component
Parameters:
propertyName - the name of the property that the listener will receive change events for.
listener - the listener that will receive PropertyChangeEvent objects upon the property changing.
See Also:
PropertyChangeListener, PropertyChangeEvent

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String[] propertyNames,
                                      PropertyChangeListener listener)
Description copied from interface: Component
Adds a PropertyChangeListener to this component that will be notified when any of the specified properties change. This method is equivalent to calling Component.addPropertyChangeListener(String, PropertyChangeListener) once for each property you want to listen to.

Specified by:
addPropertyChangeListener in interface Component
Parameters:
propertyNames - a string array of property names that the listener will receive change events for.
listener - the listerner that will receive PropertyChangeEvent objects anytime one of the specified propertyNames of this component change.
See Also:
Component.addPropertyChangeListener(String, PropertyChangeListener), PropertyChangeListener, PropertyChangeEvent

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: Component
Removes the specified PropertyChangeListener from the component. If the listener was added for multiple properties, it will be removed for all of them. NOTE: An exception is NOT thrown if you attempt to remove a listener that does not exist on this component.

Specified by:
removePropertyChangeListener in interface Component
Parameters:
listener - the listener to remove from the component.
See Also:
PropertyChangeListener

firePropertyChange

protected final boolean firePropertyChange(java.lang.Object source,
                                           java.lang.String propertyName,
                                           int oldValue,
                                           int newValue)

firePropertyChange

protected final boolean firePropertyChange(java.lang.Object source,
                                           java.lang.String propertyName,
                                           boolean oldValue,
                                           boolean newValue)

firePropertyChange

protected final boolean firePropertyChange(java.lang.Object source,
                                           java.lang.String propertyName,
                                           java.lang.Object oldValue,
                                           java.lang.Object newValue)

addActionListener

public void addActionListener(java.lang.String action,
                              ActionListener listener)
Description copied from interface: Component
Adds a ActionListener to this component that will be notified when the specified action occurs.

Specified by:
addActionListener in interface Component
Parameters:
action - the action to specficially be notified of.
listener - the event listener that will receive notification.

addActionListener

public void addActionListener(java.lang.String[] actions,
                              ActionListener listener)
Description copied from interface: Component
Adds a ActionListener to this component that will be notified when any of the specified actions occur.

Specified by:
addActionListener in interface Component
Parameters:
actions - the actions to specficially be notified of.
listener - the event listener that will receive notification.

removeActionListener

public void removeActionListener(ActionListener listener)
Description copied from interface: Component
Unregister an ActionListener from all action event notifications from this component.

Specified by:
removeActionListener in interface Component
Parameters:
listener - the listener that should no longer receive action event notifications.

fireAction

public void fireAction(ActionEvent ev)
Description copied from interface: Component
Programmatically signals an action which triggers the appropriate listener which calls the desired method.

Specified by:
fireAction in interface Component
Parameters:
ev - the event to signal

fireAction

public void fireAction(java.lang.String action)
Description copied from interface: Component
A convenience method that is equal to this.fireAction(new ActionEvent(this, action));

Specified by:
fireAction in interface Component
Parameters:
action - the action to perform on the component.

fireAction

public void fireAction(java.lang.String action,
                       java.lang.Object source)
Description copied from interface: Component
A convenience method that is equal to this.fireAction(new ActionEvent(this, action));

Specified by:
fireAction in interface Component
Parameters:
action - the action to perform on the component.

addDropListener

public void addDropListener(Component dragComponent,
                            DropListener listener)
Specified by:
addDropListener in interface Component

addDropListener

public void addDropListener(Component[] dragComponents,
                            DropListener listener)
Specified by:
addDropListener in interface Component

removeDropListener

public void removeDropListener(DropListener listener)
Specified by:
removeDropListener in interface Component

fireDrop

public void fireDrop(DropEvent ev)
Specified by:
fireDrop in interface Component

fireDrop

public void fireDrop(Component dragComponent)
Specified by:
fireDrop in interface Component

fireDrop

public void fireDrop(Component dragComponent,
                     java.lang.Object dragObject)
Specified by:
fireDrop in interface Component

addKeyPressListener

public void addKeyPressListener(java.lang.String keyPressCombo,
                                KeyPressListener listener)
Description copied from interface: Component
Adds a KeyPressListener that will be notified when the specified key press combination occurs.

For a description and list of valid keyPressCombo strings, see the documentation for KeyPressEvent.encodeKeyPressCombo(boolean, boolean, boolean, String).

Establishing keyboard shortcuts for certain features can be a highly effective way to improve the efficiency of your application. If your application has a Menu, then typically the best way to establish such shortcuts is to simply set the keyPressCombo property for each Menu.Item. Second to that, using this method to establish shortcuts on the Frame or a Dialog will have a similar wide reaching effect. Occasionally, based on the requirements of your application, you may also use this method to establish shortcuts that are only valid when a given component has focus.

Details:

When a user presses a key and/or combination, the event bubbles up the component hierarchy from the component that currently has focus and is absorbed by the first Component that has a listener asking to be notified of that event. Therefore, if both a Component and a Container up the hierarchy are listening for the same event, only the Component will receive notification. There is currently no way to cause the event to continue bubbling.

Additionally, the keyboard navigation of each Component cannot be overridden and you cannot receive notification of such events. As an example, establishing a KeyPressListener for "Space" key on the CheckBox, will have no effect because the "Space" key toggles the checked state of that component.

NOTE ON WEBBROWSERS: If no Component is listening for a given key press, then the default behavior that the browser has associated with that key press will occur. Additionally, certain key press events in certain browsers cannot be entirely circumvented. In such a case, both the action defined by a listener and the browser's default behavior will occur. An example of this is the F1 key in Internet Explorer. If you establish a listener for the F1 key, the IE help file will open in addition to whatever action you may have defined.

Example:
 Application.current().getFrame().addKeyPressListener("Ctrl-Alt-M", new KeyPressListener() {
     public void keyPress(KeyPressEvent kpe) {
         MessageBox.confirm("You pressed the following key combination: " + kpe.getKeyPressCombo());
     }
 });
 

Specified by:
addKeyPressListener in interface Component
Parameters:
keyPressCombo - a key press combo in any dash separated format supported by KeyPressEvent.normalizeKeyPressCombo(String).
listener - the listener that will receive KeyPressEvent objects upon the key press occurring.
See Also:
KeyPressListener, KeyPressEvent, KeyPressEvent.encodeKeyPressCombo(boolean, boolean, boolean, String), KeyPressEvent.normalizeKeyPressCombo(String)

addKeyPressListener

public void addKeyPressListener(java.lang.String[] keyPressCombos,
                                KeyPressListener listener)
Description copied from interface: Component
Adds a KeyPressListener that will be notified when any of the specified key press combinations occur.

For a description and list of valid keyPressCombo strings, see the documentation for KeyPressEvent.encodeKeyPressCombo(boolean, boolean, boolean, String).

See Component.addKeyPressListener(String, KeyPressListener) for a full semantic description.

Specified by:
addKeyPressListener in interface Component
Parameters:
keyPressCombos - a string array of key press combos, each in any dash separated format supported by KeyPressEvent.normalizeKeyPressCombo(String).
listener - the listener that will receive KeyPressEvent objects when any of the key presses occur.
See Also:
Component.addKeyPressListener(String, KeyPressListener), KeyPressListener, KeyPressEvent, KeyPressEvent.encodeKeyPressCombo(boolean, boolean, boolean, String), KeyPressEvent.normalizeKeyPressCombo(String)

removeKeyPressListener

public void removeKeyPressListener(KeyPressListener listener)
Description copied from interface: Component
Removes the specified KeyPressListener from the component. If the listener was added for multiple key press combinations, it will be removed for all of them. NOTE: An exception is NOT thrown if you attempt to remove a listener that does not exist on this component.

Specified by:
removeKeyPressListener in interface Component
Parameters:
listener - the listener to remove from the component.
See Also:
KeyPressListener

fireKeyPress

public void fireKeyPress(KeyPressEvent ev)
Description copied from interface: Component
Allows you to programmatically trigger a key press combination. Passing this method a valid key press combination will result in a KeyPressEvent being generated. As a result, all KeyPressListener's that are registered on the specified keyPressCombo will be notified.

For a description and list of valid keyPressCombo strings, see the documentation for KeyPressEvent.encodeKeyPressCombo(boolean, boolean, boolean, String).

Details:

A KeyPressEvent that is generated programmatically via this mechansim may, under some circumstances, have a slightly different behavior than one generated by user activity. The reason for this is that the event is only propagated within the framework itself and does not actually occur in the client. In general, this should never be an issue because the desired response to a keypress will be expressly defined by a given KeyPressListener and therefore there would be no dependence on any such side-effect. However, an example of one such difference, is in terms of a browser's default behavior for a specific key press combination. If you use this mechanism to trigger an F1 keypress, the browser's default behavior (typically bringing up a help window), will not occur.

Specified by:
fireKeyPress in interface Component
Parameters:
ev - a KeyPressEvent that represents the key press combo you want to signal has occured.

fireKeyPress

public void fireKeyPress(java.lang.String keyPressCombo)
Description copied from interface: Component
A convenience method that is equal to this.fireKeyPress(new KeyPressEvent(keyPressCombo, this));

Specified by:
fireKeyPress in interface Component
Parameters:
keyPressCombo - a key press combo in any dash separated format supported by KeyPressEvent.normalizeKeyPressCombo(String).
See Also:
KeyPressEvent.encodeKeyPressCombo(boolean, boolean, boolean, String), KeyPressEvent.normalizeKeyPressCombo(String)

getParent

public java.lang.Object getParent()
Description copied from interface: Component
Returns the parent Object of this Component. If you specifically need the parent Container of this Component use Component.getContainer() instead.
Details:

Under the majority of situations, the returned value is either a Container or null since a Component will either be a child of a Container or not attached to any object. However, in some cases the parent of the Component may be another Component, or a completely different kind of Object. For example, in the case of the DropDownGridBox, there is an actual GridBox that is a child of the drop down. Therefore, the parent of that GridBox would be the DropDownGridBox. Another situation exists when you use a multi-tiered GridBox, meaning a GridBox that has one or more "pop-up" child GridBox's. Under that scenario, the parent of the child's GridBox is actually an instance of GridBox.Row and the parent of the row is the GridBox.

Specified by:
getParent in interface Component
Returns:
the parent Object of this Component, or null if no parent exists.
See Also:
Component.getContainer()

getContainer

public Container getContainer()
Description copied from interface: Component
Returns the parent Container of this Component. Unlike getParent(), this method guarantees that if a non-null value is returned, it will be a Contaienr.

Specified by:
getContainer in interface Component
Returns:
the parent Container of this Component, or null if no parent exists.
See Also:
Component.getParent()

getLabel

public Label getLabel()
Description copied from interface: Component
Returns the Label assigned to this Component. This property is part of a two-way relationship that is established by the Label.setLabelFor(Component) property. There is no setLabel method, instead use Label.setLabelFor(Component).

Specified by:
getLabel in interface Component
Returns:
the Label assigned to this Component.

getUserObject

public java.lang.Object getUserObject()
Description copied from interface: Component
Returns the user defined Object for this Component.
Default: null

Specified by:
getUserObject in interface Component
Returns:
the user defined Object for this Component, or null if no value has been specified.
See Also:
Component.setUserObject(Object)

setUserObject

public void setUserObject(java.lang.Object userObject)
Description copied from interface: Component
Assigns a user defined Object to this Component. This property has no direct effect on the state of the Component. Instead, it provides a general purpose storage mechanism to the developer that allows any kind of data to be associated to this Component. For complex applications, alternate methods of associating state to a Component will likely serve your design more thoroughly. However, there are a number of cases where this flexibility could be useful and therefore the framework supports the concept.
Default: null

Refer to the documenation on Application.addGlobalPropertyChangeListener(String, PropertyChangeListener) for an example of a potential use of this property.

Events:

If the prior value and new value differ, setting this property causes a PropertyChangeEvent ( propertyName = PROPERTY_USER_OBJECT ) to be generated.

Specified by:
setUserObject in interface Component
Parameters:
userObject - an Object of any type that is to be associated with this Component.
See Also:
Component.getUserObject(), Application.addGlobalPropertyChangeListener(String, PropertyChangeListener), Component.PROPERTY_USER_OBJECT, PropertyChangeEvent

isEnabled

public boolean isEnabled()
Description copied from interface: Component
Returns whether this Component is enabled and therefore supports user interaction.
Default: true

Specified by:
isEnabled in interface Component
Returns:
true if the Component supports user interaction, false otherwise.
See Also:
Component.setEnabled(boolean)

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: Component
Assigns whether this Component is enabled and therefore supports user interaction. The form of user iteraction this property controls, depends on the specific kind of Component itself. However, in general, all keyboard interaction and mouse interaction is disabled by setting this property to false.
Default: true
Events:

If the prior value and new value differ, setting this property causes a PropertyChangeEvent ( propertyName = PROPERTY_ENABLED ) to be generated.

Specified by:
setEnabled in interface Component
Parameters:
enabled - true to allow user interaction, false to disallow it.
See Also:
Component.isEnabled(), Component.PROPERTY_ENABLED, PropertyChangeEvent

isFocusCapable

public boolean isFocusCapable()
Description copied from interface: Component
Returns whether this Component supports gaining focus.
Default: true, except for Divider, Image and Label.

Specified by:
isFocusCapable in interface Component
Returns:
true if this Component supports gaining focus, false otherwise.
See Also:
Component.setFocusCapable(boolean), Component.setFocus(boolean)

setFocusCapable

public void setFocusCapable(boolean focusCapable)
Description copied from interface: Component
Assigns whether this Component supports gaining focus.
Default: true, except for Divider, Image and Label.
Events:

If the prior value and new value differ, setting this property causes a PropertyChangeEvent ( propertyName = PROPERTY_FOCUS_CAPABLE ) to be generated.

Specified by:
setFocusCapable in interface Component
Parameters:
focusCapable - true to allow this component to receive focus, false to disallow it.
See Also:
Component.isFocusCapable(), Component.PROPERTY_FOCUS_CAPABLE, Component.setFocus(boolean), PropertyChangeEvent

isFocus

public final boolean isFocus()
Description copied from interface: Component
Returns whether this Component has the input focus. If this is a Container, then this method will return true if a child Component has the focus. In such a case, you can use the Container.getChildWithFocus() method to get a reference to that child. Similarly, if you want to find the child Component that has the focus anywhere in the current Frame or Dialog, you can use the Container.getComponentWithFocus() method.

Default: false. However, at rendering time, if no component in the window has focus, the first focus capable component is given focus.

See the Component.setFocus(boolean) method for a full description of focus details.

Specified by:
isFocus in interface Component
Returns:
true if this Component has the input focus, false otherwise.
See Also:
Component.setFocus(boolean), Container.getComponentWithFocus(), Container.getChildWithFocus()

setFocus

public void setFocus(boolean focus)
Description copied from interface: Component
Assigns whether this Component has the input focus. When this Component has the input focus, it will receive all keyboard events generated by the user. Therefore, if this Component supports text editing and it has focus, the user can type a value into it's field. Additionally, any keyboard navigation supported by this Component or keyboard shortcuts added by a developer become available upon gaining focus. Conversely, when this Component no longer has focus, it will receive no keyboard events.

Default: false. However, at rendering time, if no component in the window has focus, the first focus capable component is given focus.

Details:

The simplest of all cases, is when this Component has not yet been added to a Container. In that scenario, the focus property is simply set to true and no other effect occurs. Later, when this Component is added to a Container it will be given the focus according to the guidelines that follow.

As a general rule, only a single Component can have the focus per Frame or Dialog container hierarchy. In terms of the user interface, only a single Component will actually have the focus regardless of whether a Dialog and the Frame have components with focus. In such a case, the actual focus is determined based on which window is currently active.

Since only one Component per window can have focus, giving this Component focus will cause the prior Component of the window to lose focus. In the most common case, both this Component and the Component losing focus will be siblings in the same Container. In that case, the focus property of the Component losing focus is simply set to false whereas the focus property of this Component is set to true.

More complex scenarios arise when the Component losing focus and this Component are not siblings in the same Container. In those cases, the order in which focus is lost and gained occurs as follows:

The final case to be aware of is if you directly set this Component's focus to false. In that case, the same loss of focus rules outlined above apply. There is simply no gaining of focus that occurs by any component. Therefore you cause the window to have no Component with focus, with the except of the parent Container of this Component.

Events:

If the prior value and new value differ, setting this property causes a PropertyChangeEvent ( propertyName = PROPERTY_FOCUS ) to be generated. Additionally, similar event generation may occur for other components according to the details outlined above.

Specified by:
setFocus in interface Component
Parameters:
focus - true to give this Component and it's parent containers focus, false otherwise.
See Also:
Component.isFocus(), Container.getComponentWithFocus(), Container.getChildWithFocus()

getStyle

public Style getStyle()
Description copied from interface: Component
Returns a Style object representing this Component's current style settings. NOTE: This method will never return null.

Specified by:
getStyle in interface Component
Returns:
a Style object representing this Component's current style settings.
See Also:
Style

setPosition

public Component setPosition(int x,
                             int y)
Description copied from interface: Component
Assigns the specified X and Y coordinates to this Component atomically, in one operation. Aside from the convienence provided by this method, it also guarantees that both of the provided X and Y coordinates are legal values before the values are committed. The primary benefit of this is that no PropertyChangeEvent's will be generated until both values have been set. Events:

This method may generate PropertyChangeEvent's. See the documenation of setX and setY for more details.

Specified by:
setPosition in interface Component
Parameters:
x - the x coordinate (in pixels) to assign to this Component
y - the y coordinate (in pixels) to assign to this Component
Returns:
this Component so that you can perform operations like container.getChildren().add(new Button().setPosition(x, y))
See Also:
Component.setX(int), Component.setY(int), Component.setBounds(int, int, int, int), Component.PROPERTY_X, Component.PROPERTY_Y, PropertyChangeEvent

getWidth

public int getWidth()
Description copied from interface: Component
Returns the width of this Component.

Specified by:
getWidth in interface Component
Returns:
the width (in pixels) of this Component
See Also:
Component.setWidth(int)

getHeight

public int getHeight()
Description copied from interface: Component
Returns the height of this Component.

Specified by:
getHeight in interface Component
Returns:
the height (in pixels) of this Component
See Also:
Component.setHeight(int)

setSize

public Component setSize(int width,
                         int height)
Description copied from interface: Component
Assigns the specified width and height to this Component atomically, in one operation. Aside from the convienence provided by this method, it also guarantees that both of the provided width and height are legal values before the values are committed. The primary benefit of this is that no PropertyChangeEvent's will be generated until both values have been set. Events:

This method may generate PropertyChangeEvent's. See the documenation of setWidth and setHeight for more details.

Specified by:
setSize in interface Component
Parameters:
width - the width (in pixels) to assign to this Component
height - the height (in pixels) to assign to this Component
Returns:
this Component so that you can perform operations like container.getChildren().add(new Button().setSize(width, height))
See Also:
Component.setWidth(int), Component.setHeight(int), Component.setBounds(int, int, int, int), Component.PROPERTY_WIDTH, Component.PROPERTY_HEIGHT, PropertyChangeEvent

setBounds

public Component setBounds(int x,
                           int y,
                           int width,
                           int height)
Description copied from interface: Component
Assigns the specified width, height, X and Y values to this Component atomically, in one operation. Aside from the convienence provided by this method, it also guarantees that all of the provided values are legal before they are committed. The primary benefit of this is that no PropertyChangeEvent's will be generated until all values have been set. Events:

This method may generate PropertyChangeEvent's. See the documenation of setX, setY, setWidth and setHeight for more details.

Specified by:
setBounds in interface Component
Parameters:
x - the x coordinate (in pixels) to assign to this Component
y - the y coordinate (in pixels) to assign to this Component
width - the width (in pixels) to assign to this Component
height - the height (in pixels) to assign to this Component
Returns:
this Component so that you can perform operations like container.getChildren().add(new Button().setBounds(x, y, width, height))
See Also:
Component.setX(int), Component.setY(int), Component.setWidth(int), Component.setHeight(int), Component.setBounds(int, int, int, int), Component.PROPERTY_X, Component.PROPERTY_Y, Component.PROPERTY_WIDTH, Component.PROPERTY_HEIGHT, PropertyChangeEvent

getLimit

public java.lang.Object getLimit()
Description copied from interface: Component
Gets the layout limit that controls the bounds of this component within the context of the parent Container's layout.

Specified by:
getLimit in interface Component
Returns:
the layout limit that is in use by the Container's layout, or null if no limit is specified.
See Also:
Component.setLimit(Object), Container.getLayout(), Container.setLayout(thinwire.ui.layout.Layout), Layout

setLimit

public Component setLimit(java.lang.Object limit)
Description copied from interface: Component
Sets a layout limit that controls the bounds of this component within the context of the parent Container's layout. The type of limit object that is acceptable depends on the Layout that is specified for the parent Container. Default: null

Specified by:
setLimit in interface Component
Parameters:
limit - a layout limit to use for the Container's layout, or null to clear the limit.
Returns:
this Component so that you can perform operations like container.getChildren().add(new Button().setLimit(...))
See Also:
Component.PROPERTY_LIMIT, Component.getLimit(), Container.getLayout(), Container.setLayout(thinwire.ui.layout.Layout), Layout, PropertyChangeEvent

isVisible

public boolean isVisible()
Description copied from interface: Component
Returns a boolean value indicating whether this Component may be displayed in a window. See the documentation of Component.setVisible(boolean) for further details about this property.
Default: true, except for the Dialog and Frame containers.

Specified by:
isVisible in interface Component
Returns:
true if this Component may be displayed, fasle otherwise
See Also:
Component.setVisible(boolean)


ThinWire® is a registered of Custom Credit Systems  Copyright © 2007 All rights reserved.
ThinWire_is_Open_Source_under_the_terms_of_the_LGPLv2.1 SourceForge.net_Project_Page java.net_Member Support_ThinWire,_Digg_our_Story