public class AlignedLabelsContainer extends Container
AlignedLabelsContainer
is a Container
used to align all controls to the maximum width of a set of labels. You can
define the label alignment. The controls that you add to this container are placed at the right of the labels. Here's a sample of how to use it:
String[] labels = { "Name", "Born date", "Telephone", "Address", "City", "Country", "", }; AlignedLabelsContainer c = new AlignedLabelsContainer(labels); c.setBorderStyle(BORDER_LOWERED); c.labelAlign = RIGHT; c.foreColors = new int[]{Color.RED,Color.BLACK,Color.BLACK,Color.BLACK,Color.BLACK,Color.BLACK,Color.BLACK,}; c.setInsets(2,2,2,2); c.setFont(font.asBold()); // labels are bold c.childrenFont = font; // but controls are normal add(c,LEFT+2,TOP+2,FILL-2,PREFERRED+4); for (int i =0; i < labels.length-2; i++) c.add(new Edit(),LEFT+2,AFTER+(i==0?2:0)); c.add(new ComboBox(new String[]{"Brazil","France"}),LEFT+2,AFTER); c.add(new Button("Insert data"),RIGHT,SAME); c.add(new Button("Clear data"),RIGHT,AFTER,SAME,PREFERRED);
Control.TranslucentShape
Modifier and Type | Field and Description |
---|---|
Font |
childrenFont
Sets this member to the font you want to set to the controls that are added to this container.
|
int[] |
foreColors
Sets an array with the same number of labels and the colors you want to show for each label.
|
int |
labelAlign
The alignment of the labels.
|
protected java.lang.String[] |
labels
The label captions.
|
protected int[] |
widths
The computed widths for the labels.
|
alwaysEraseBackground, BACKGROUND_CYLINDRIC_SHADED, BACKGROUND_SHADED, BACKGROUND_SHADED_INV, BACKGROUND_SOLID, backgroundStyle, BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_ROUNDED, BORDER_SIMPLE, BORDER_TOP, borderColor, borderRadius, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, lastX, lastY, numChildren, started, tabOrder, tail, TRANSITION_TIME
AFTER, alphaValue, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, BRIGHTER_BACKGROUND, callListenersOnAllTargets, CENTER, CENTER_OF, clearValueInt, clearValueStr, DARKER_BACKGROUND, DP, effect, enableUpdateScreen, esce, eventsEnabled, FILL, fillColor, FIT, floating, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, FONTSIZE, foreColor, height, ignoreInsets, isHighlighting, isTablet, KEEP, keepDisabled, keepEnabled, LEFT, next, nextTabControl, npParts, offscreen, offscreen0, onEventFirst, parent, PARENTSIZE, PARENTSIZEMAX, PARENTSIZEMIN, PREFERRED, prev, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, SCREENSIZE, SCREENSIZEMAX, SCREENSIZEMIN, setFont, setH, setRel, setW, setX, SETX_NOT_SET, setY, tempW, textShadowColor, TOP, translucentShape, transparentBackground, uiAdjustmentsBasedOnFontHeightIsSupported, uiAndroid, UICONST, uiFlat, uiHolo, uiMaterial, uiVista, visible, width, WILL_RESIZE, x, y
Constructor and Description |
---|
AlignedLabelsContainer()
Creates a new
AlignedLabelsContainer without labels. |
AlignedLabelsContainer(java.lang.String[] labels)
Creates a new
AlignedLabelsContainer with the given labels. |
AlignedLabelsContainer(java.lang.String[] labels,
int vgap)
Creates a new
AlignedLabelsContainer with the given labels. |
Modifier and Type | Method and Description |
---|---|
void |
add(Control c)
Since this is an
AlignedLabelsContainer , use this to add a label. |
int |
getLeftInset()
Returns the left inset.
|
int |
getLineHeight()
Returns the height of a line.
|
int |
getLineY(int line)
Given a line (staring from 0), returns the y position.
|
int |
getPreferredHeight()
Returns the preferred height of this control.
|
int |
getPreferredWidth()
Returns the preferred width of this control.
|
void |
onFontChanged()
Called after a
setFont() |
void |
onPaint(Graphics g)
Draws the border (if any).
|
void |
setInsets(int left,
int right,
int top,
int bottom)
Sets the insets value to match the given ones.
|
void |
setLabels(java.lang.String[] labels,
int vgap)
Sets the labels and the extra gap between rows (which may be 0).
|
add, add, add, add, broadcastEvent, clear, fillBackground, findChild, findNearestChild, findNextFocusControl, getBorderRadius, getBorderStyle, getChildren, getChildrenCount, getClientRect, getClientRect, getFirstChild, getFocusableControls, getInsets, incLastX, incLastY, initUI, isPressed, moveFocusToNextControl, moveFocusToNextEditable, onAddAgain, onColorsChanged, onRemove, onSwapFinished, paintChildren, remove, removeAll, resize, resizeHeight, resizeWidth, setBorderRadius, setBorderStyle, setEnabled, setFocusTraversable, setHighlighting, setPressColor, setPressed, swapToTopmostWindow
_onEvent, addEnabledStateListener, addFocusListener, addFontChangeHandler, addGridListener, addHandler, addHighlightListener, addKeyListener, addListContainerListener, addMouseListener, addMultiTouchListener, addPenListener, addPressListener, addPushNotificationListener, addSizeChangeHandler, addTimer, addTimer, addTimerListener, addValueChangeHandler, addWindowListener, bringToFront, changeHighlighted, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getDoEffect, getEffectH, getEffectW, getEffectX, getEffectY, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, handleGeographicalFocusChangeKeys, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isFloating, isInsideOrNear, isObscured, isTopMost, isVisible, isVisibleAndInside, onBoundsChanged, onEvent, onWindowPaintFinished, post, postEvent, postPressedEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHandler, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, reposition, repositionChildren, requestFocus, resetSetPositions, resetStyle, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setDoEffect, setFloating, setFocusLess, setFont, setForeColor, setNinePatch, setNinePatch, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
protected java.lang.String[] labels
protected int[] widths
public Font childrenFont
public int[] foreColors
public int labelAlign
LEFT
.Control.LEFT
,
Control.CENTER
,
Control.RIGHT
public AlignedLabelsContainer()
AlignedLabelsContainer
without labels. You may call setLabels()
to set the labels.public AlignedLabelsContainer(java.lang.String[] labels)
AlignedLabelsContainer
with the given labels.labels
- The strings that represents the labels. You may pass null
, but be sure to call setLabels()
to set the
labels.AlignedLabelsContainer(String[], int)
,
setLabels(String[], int)
public AlignedLabelsContainer(java.lang.String[] labels, int vgap)
AlignedLabelsContainer
with the given labels.labels
- The strings that represents the labels. You may pass null
, but be sure to call setLabels()
to set the
labels.vgap
- The extra gap between rows. May be negative.AlignedLabelsContainer(String[])
,
setLabels(String[], int)
public void setLabels(java.lang.String[] labels, int vgap)
labels
- The strings that represents the labels. You may pass null
, but be sure to call setLabels()
again to
set the labels with a valid value.vgap
- The extra gap between rows. May be negative.AlignedLabelsContainer(String[])
,
AlignedLabelsContainer(String[], int)
public void onFontChanged()
setFont()
onFontChanged
in class Control
public void add(Control c)
AlignedLabelsContainer
, use this to add a label.public void setInsets(int left, int right, int top, int bottom)
public int getPreferredWidth()
getPreferredWidth
in class Control
public int getPreferredHeight()
getPreferredHeight
in class Control
public void onPaint(Graphics g)
public int getLineY(int line)
add(chCasado = new Check("Married"),LEFT,getLineY(4)+2);
public int getLineHeight()
public int getLeftInset()
control.setRect(CENTER-getLeftInset()/2,...);