|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.swt.widgets.Widget org.eclipse.swt.widgets.Control org.eclipse.swt.widgets.Scrollable org.eclipse.swt.widgets.Composite org.eclipse.ercp.swt.mobile.CaptionedControl
A CaptionedControl is used to display a label (caption) in front of a control. An optional trailing text can be used after the control, for example, to indicate units of measurement.
The highlighting is implementation dependent. Typically, a focused
CaptionedControl will highlight all its elements, i.e. the leading label, the
control, and optional trailing label, when it gets focus. The positioning
order for the captions is determined by the SWT.LEFT_TO_RIGHT
and SWT.RIGHT_TO_LEFT
styles hints.
CaptionedControl does not support nested CaptionedControls. An exception will be thrown when an instance of CaptionedControl is given as the constructor's argument. To change the control contained by the CaptionedControl, a new control can be created using the CaptionedControl as its parent control. The old control must be disposed by the application manually. Only one control can be active and visible in a CaptionedControl. Which control is displayed when multiple controls have been added is implementation-dependent.
Example code:
CaptionedControl control = new CaptionedControl(shell, SWT.NONE);
ConstraintedText currency = new ConstraintedText(control, SWT.NONE,
ConstraintedText.NUMERIC);
control.setText("Velocity");
control.getTrailingText("cm");
Note: Even though this class is a subclass of Composite, setting a layout on it is not supported.
IMPORTANT: This class is not intended to be subclassed.
Constructor Summary | |
CaptionedControl(Composite parent,
int style)
Constructs a new instance of this class given its parent and a style value describing its behavior and appearance. |
Method Summary | |
Image |
getImage()
Returns the CaptionedControl's icon image, or null if it has never been set. |
java.lang.String |
getText()
Gets the caption text, which will be an empty string if it has never been set. |
java.lang.String |
getTrailingText()
Gets the trailing text, which will be an empty string if it has never been set. |
void |
setImage(Image image)
Sets the image as an icon to the CaptionedControl. |
void |
setText(java.lang.String string)
Sets the caption label |
void |
setTrailingText(java.lang.String string)
Sets the trailing label |
Methods inherited from class org.eclipse.swt.widgets.Composite |
checkSubclass, getChildren, getLayout, getTabList, layout, layout, setLayout, setTabList |
Methods inherited from class org.eclipse.swt.widgets.Scrollable |
computeTrim, getClientArea, getHorizontalBar, getVerticalBar |
Methods inherited from class org.eclipse.swt.widgets.Widget |
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public CaptionedControl(Composite parent, int style)
The style value is either one of the style constants defined in class
SWT
which is applicable to instances of this class, or
must be built by bitwise OR 'ing together (that is, using the
int
"|" operator) two or more of those SWT
style constants. The class description lists the style constants that are
applicable to the class. Style bits are also inherited from superclasses.
parent
- a widget which will be the parent of the new instance (cannot
be null)style
- the style of widget to construct
java.lang.IllegalArgumentException
- SWTException
- SWT.LEFT_TO_RIGHT
,
SWT.RIGHT_TO_LEFT
Method Detail |
public void setText(java.lang.String string)
string
- the new caption label
java.lang.IllegalArgumentException
- ERROR_NULL_ARGUMENT
if the text is null
SWTException
- getText()
public void setTrailingText(java.lang.String string)
string
- the new trailing label
java.lang.IllegalArgumentException
- SWTException
- getTrailingText()
public java.lang.String getText()
SWTException
- setText(java.lang.String)
public java.lang.String getTrailingText()
SWTException
- setTrailingText(java.lang.String)
public void setImage(Image image)
The parameter can be null indicating that no image should be displayed. The implementation will adjust the image size to make it best fit the CaptionedControl.
image
- the image to display on the receiver
java.lang.IllegalArgumentException
- SWTException
- public Image getImage()
SWTException
- setImage(Image)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |