com.droplets.api
Class Label

java.lang.Object
  |
  +--com.droplets.api.Component
        |
        +--com.droplets.api.Label
Direct Known Subclasses:
LabelButton

public class Label
extends Component

A Label GUI component. A label is simply a freestanding string that appears directly on a panel.

Labels support drag and drop. You need to pass the Component you want to accept drops from to the addAcceptDrop function. You then need to add a DropListener via a call to addDropListener. When a drop occurs we will generate a DropEvent. This DropEvent will be handled by DropListener class you created and added above.

Aside from the standard set of Component properties and those defined in the DragAndDrop interface, Label defines several of its own:

As usual, all of these properties have getters and setters that use the JavaBeans naming conventions.


Field Summary
static java.lang.String ALIGN_CENTER
          Constant used by the alignment property to indicate centered alignment
static java.lang.String ALIGN_LEFT
          Constant used by the alignment property to indicate left alignment
static java.lang.String ALIGN_RIGHT
          Constant used by the alignment property to indicate right alignment
 
Fields inherited from class com.droplets.api.Component
ANCHOR_CENTER, ANCHOR_EAST, ANCHOR_NORTH, ANCHOR_NORTHEAST, ANCHOR_NORTHWEST, ANCHOR_SOUTH, ANCHOR_SOUTHEAST, ANCHOR_SOUTHWEST, ANCHOR_WEST, FILL_BOTH, FILL_HORIZONTAL, FILL_NONE, FILL_VERTICAL
 
Constructor Summary
Label(LayoutPlacement p, java.lang.String text, Window window)
          Constructs a new Label.
 
Method Summary
protected  void action(java.lang.String action, java.lang.String args)
          Called by the server when the user has performed an action on this component.
 void addAcceptDrop(Component c)
          Add a valid target for us to accept drop messages from.
 void addDropListener(DropListener l)
          Add a DropListener that will be called when a drop occurs on this component.
 java.lang.String getAlignment()
          Gets the text alignment.
 Color getDragOverBgColor()
          Gets the background color of the row that the mouse is being dragged over.
 Color getDragOverFgColor()
          Gets the foreground color of the row that the mouse is being dragged over.
 boolean getIsMoveHandle()
          if true, the label will move the parent window if it is dragged.
 int getMargin()
          Gets the number of pixels to leave in between the text and the sides of this label.
 boolean getShadow()
          Determines whether shadowing of the text is on or off.
 int getWidth()
          Gets the preferred width.
protected  boolean isFocusTraversableDefault()
          See Component.isFocusTraversableDefault().
 void removeAcceptDrop(Component c)
          Stop accepting drop messages from the specified target.
 void removeDropListener(DropListener l)
          Remove a DropListener that was added previously.
 void setAlignment(java.lang.String value)
          Specifies whether text should be left-aligned, right-aligned, or centered.
 void setAlignment(java.lang.String value, java.lang.String skin)
          Specifies whether text should be left-aligned, right-aligned, or centered.
 void setDragOverBgColor(Color c)
          Sets the background color of the row that the mouse is being dragged over.
 void setDragOverBgColor(Color c, java.lang.String skin)
          Sets the background color of the row that the mouse is being dragged over.
 void setDragOverFgColor(Color c)
          Sets the foreground color of the row that the mouse is being dragged over.
 void setDragOverFgColor(Color c, java.lang.String skin)
          Sets the foreground color of the row that the mouse is being dragged over.
 void setIsMoveHandle(boolean value)
          if true, the label will move the parent window if it is dragged.
 void setIsMoveHandle(boolean value, java.lang.String skin)
          if true, the label will move the parent window if it is dragged.
 void setMargin(int value)
          Sets the number of pixels to leave in between the text and the sides of this label.
 void setMargin(int value, java.lang.String skin)
          Sets the number of pixels to leave in between the text and the sides of this label.
 void setShadow(boolean value)
          Turns shadowing of the text on or off.
 void setShadow(boolean value, java.lang.String skin)
          Turns shadowing of the text on or off.
 void setWidth(int value)
          Sets the preferred width.
 void setWidth(int value, java.lang.String skin)
          Sets the preferred width.
 
Methods inherited from class com.droplets.api.Component
addActionListener, addAttributeChangeListener, addValueChangeListener, attributeChanged, constructionFailed, equals, fireActionEvent, fireAttributeChangeEvent, fireValueChangeEvent, getAnchor, getAttribute, getBgColor, getBoolAttribute, getBordersAttribute, getColorAttribute, getCursor, getCursorType, getDoubleAttribute, getEnabled, getFgColor, getFill, getFont, getGridHeight, getGridWidth, getGridX, getGridY, getInsets, getIntAttribute, getIPadX, getIPadY, getOpaque, getParent, getScriptingName, getSpecification, getStringAttribute, getToolTip, getValue, getVisible, getWeightX, getWeightY, getWindow, invalidate, isAddedToWindow, isContainer, isFocusTraversable, isValid, removeActionListener, removeAttributeChangeListener, removeValueChangeListener, requestFocus, reset, sendCommandAttribute, setAnchor, setAnchor, setArg, setAttribute, setBgColor, setBgColor, setBoolAttribute, setBordersAttribute, setColorAttribute, setCursor, setCursor, setCursorType, setDoubleAttribute, setEnabled, setEnabled, setEnterButton, setEnterButton, setEnterButton, setFgColor, setFgColor, setFill, setFill, setFocusTraversable, setFont, setFont, setGridHeight, setGridHeight, setGridWidth, setGridWidth, setGridX, setGridX, setGridY, setGridY, setInsets, setInsets, setIntAttribute, setIPadX, setIPadX, setIPadY, setIPadY, setItemListAttribute, setOpaque, setOpaque, setScriptingName, setStringAttribute, setToolTip, setValue, setValue, setVisible, setVisible, setWeightX, setWeightX, setWeightY, setWeightY, storeAttribute, valueChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALIGN_LEFT

public static final java.lang.String ALIGN_LEFT
Constant used by the alignment property to indicate left alignment

ALIGN_CENTER

public static final java.lang.String ALIGN_CENTER
Constant used by the alignment property to indicate centered alignment

ALIGN_RIGHT

public static final java.lang.String ALIGN_RIGHT
Constant used by the alignment property to indicate right alignment
Constructor Detail

Label

public Label(LayoutPlacement p,
             java.lang.String text,
             Window window)
Constructs a new Label.
Parameters:
p - specifies how this component should be laid out in the enclosing panel (see LayoutPlacement)
text - the initial text (considered the label's value, so it will be returned by Component.getValue()
window - the window in which this component will be placed
Method Detail

setWidth

public void setWidth(int value,
                     java.lang.String skin)
Sets the preferred width.
Parameters:
value - width in pixels

setWidth

public void setWidth(int value)
Sets the preferred width.
Parameters:
value - width in pixels

getWidth

public int getWidth()
Gets the preferred width.
Returns:
width in pixels

setAlignment

public void setAlignment(java.lang.String value,
                         java.lang.String skin)
Specifies whether text should be left-aligned, right-aligned, or centered.
Parameters:
value - the desired alignment constant. Must be one of Label.ALIGN_CENTER, Label.ALIGN_LEFT, or Label.ALIGN_RIGHT.
skin - skin name to use for this attribute

setAlignment

public void setAlignment(java.lang.String value)
Specifies whether text should be left-aligned, right-aligned, or centered.
Parameters:
value - the desired alignment constant. Must be one of Label.ALIGN_CENTER, Label.ALIGN_LEFT, or Label.ALIGN_RIGHT.

getAlignment

public java.lang.String getAlignment()
Gets the text alignment.
Returns:
one of Label.ALIGN_CENTER, Label.ALIGN_LEFT, or Label.ALIGN_RIGHT

setShadow

public void setShadow(boolean value,
                      java.lang.String skin)
Turns shadowing of the text on or off.
Parameters:
value - true to turn shadowing on, false to turn it off
skin - skin name to use for this attribute

setShadow

public void setShadow(boolean value)
Turns shadowing of the text on or off.
Parameters:
value - true to turn shadowing on, false to turn it off

getShadow

public boolean getShadow()
Determines whether shadowing of the text is on or off.
Returns:
true if shadowing is on, false if it's off

setMargin

public void setMargin(int value,
                      java.lang.String skin)
Sets the number of pixels to leave in between the text and the sides of this label. Has no effect if the alignment is set to ALIGN_CENTER.
Parameters:
value - the desired margin
skin - skin name to use for this attribute

setMargin

public void setMargin(int value)
Sets the number of pixels to leave in between the text and the sides of this label. Has no effect if the alignment is set to ALIGN_CENTER.
Parameters:
value - the desired margin

getMargin

public int getMargin()
Gets the number of pixels to leave in between the text and the sides of this label. This number is meaningless when the alignment is set to ALIGN_CENTER.
Returns:
margin, in pixels

action

protected void action(java.lang.String action,
                      java.lang.String args)
Description copied from class: Component
Called by the server when the user has performed an action on this component. Subclasses should overridde to handle any actions that they need to handle in a special way - for example, if they maintain a separate listener list for some kinds of actions. If a subclass gets an action it doesn't recognize or is not interested in, it should pass the call on to this implementation in order to support notification of ActionListeners.
Overrides:
action in class Component
Following copied from class: com.droplets.api.Component
Parameters:
action - Identifies the type of action that occurred
args - Action-specific arguments (extra information)

getIsMoveHandle

public boolean getIsMoveHandle()
if true, the label will move the parent window if it is dragged.
Returns:
true if the label is a move handle.

setIsMoveHandle

public void setIsMoveHandle(boolean value,
                            java.lang.String skin)
if true, the label will move the parent window if it is dragged.
Parameters:
value - true if the label should be a move handle.
skin - the skin name to use for this attribute

setIsMoveHandle

public void setIsMoveHandle(boolean value)
if true, the label will move the parent window if it is dragged.
Parameters:
value - true if the label should be a move handle.

getDragOverBgColor

public Color getDragOverBgColor()
Gets the background color of the row that the mouse is being dragged over.
Returns:
Current value of the attribute.

getDragOverFgColor

public Color getDragOverFgColor()
Gets the foreground color of the row that the mouse is being dragged over.
Returns:
Current value of the attribute.

setDragOverBgColor

public void setDragOverBgColor(Color c,
                               java.lang.String skin)
Sets the background color of the row that the mouse is being dragged over.
Parameters:
c - Desired value of this attribute.
skin - The name to use for this attribute in the skin files.

setDragOverBgColor

public void setDragOverBgColor(Color c)
Sets the background color of the row that the mouse is being dragged over.
Parameters:
c - Desired value of this attribute.

setDragOverFgColor

public void setDragOverFgColor(Color c,
                               java.lang.String skin)
Sets the foreground color of the row that the mouse is being dragged over.
Parameters:
c - Desired value of this attribute.
skin - The name to use for this attribute in the skin files.

setDragOverFgColor

public void setDragOverFgColor(Color c)
Sets the foreground color of the row that the mouse is being dragged over.
Parameters:
c - Desired value of this attribute.

addDropListener

public void addDropListener(DropListener l)
Add a DropListener that will be called when a drop occurs on this component.
Parameters:
l - The listener to be informed when a drop occurs.

removeDropListener

public void removeDropListener(DropListener l)
Remove a DropListener that was added previously.
Parameters:
l - The listener of interest.

addAcceptDrop

public void addAcceptDrop(Component c)
Add a valid target for us to accept drop messages from.
Parameters:
c - The component to accept drop messages from.

removeAcceptDrop

public void removeAcceptDrop(Component c)
Stop accepting drop messages from the specified target.
Parameters:
c - The component that no longer will send drop messages to us.

isFocusTraversableDefault

protected boolean isFocusTraversableDefault()
See Component.isFocusTraversableDefault().
Overrides:
isFocusTraversableDefault in class Component
Following copied from class: com.droplets.api.Component
See Also:
Component.setFocusTraversable(boolean)


Copyright © Droplets, 2001. All Rights Reserved.