public class PushButtonGroup extends Control
new PushButtonGroup(new String[]{"Button1","Button2","Button3"},false,-1,-1,4,0,false,PushButtonGroup.NORMAL)
The width of each button is calculated based on its caption size plus the insideGap, if you use PREFERRED as the width; otherwise, it uses the size you specified (E.G.: FILL, FIT, etc). The height is calculated based on the font's size or on the height you specified.
Control.TranslucentShape
Modifier and Type | Field and Description |
---|---|
int |
AUTO_DELAY
The frequency in which the PRESSED event will be posted after the INITIAL_DELAY was reached.
|
boolean |
autoRepeat
Set to true to enable auto-repeat feature for this button.
|
static byte |
BUTTON
The button will be selected and unselected immediately, acting like a real button
|
static byte |
CHECK
One click in the button will select it and another click will unselect it.
|
boolean |
checkAppearsRaised
Set to true to make the CHECK mode appear as raised by default (default is: button lowered when not selected).
|
int[] |
colspan
Span across multiple columns and rows.
|
boolean[] |
hidden
The boolean array that defines which buttons are hidden.
|
int |
INITIAL_DELAY
The initial delay to start the auto-repeat.
|
int |
insideGap
Space between the text and the button border.
|
java.lang.String[] |
names |
static byte |
NORMAL
Normal: only one selected at a time
|
Rect[] |
rects
The bounds of each of the buttons.
|
int[] |
rowspan
Span across multiple columns and rows.
|
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 |
---|
PushButtonGroup(java.lang.String[] names,
boolean atLeastOne,
int selected,
int gap,
int insideGap,
int rows,
boolean allSameWidth,
byte type)
Create the button matrix.
|
PushButtonGroup(java.lang.String[] names,
int gap,
int rows)
Create the button matrix, with insideGap = 4, selected = -1, atLeastOne = false, allSameWidth = true and type = BUTTON.
|
PushButtonGroup(java.lang.String[] names,
int gap,
int insideGap,
int rows)
Create the button matrix, with selected = -1, atLeastOne = false, allSameWidth = false and type = BUTTON.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears this control, selecting index clearValueInt.
|
int |
getEffectH() |
int |
getEffectW() |
int |
getEffectX() |
int |
getEffectY() |
int |
getHighlightColor() |
boolean |
getHighlightEmptyValues() |
boolean |
getHighlightSelected() |
int |
getPreferredHeight()
Returns the preferred height of this control.
|
int |
getPreferredWidth()
Returns the preferred width of this control.
|
int |
getSelectedIndex()
Returns the index of the selected button, or -1 if none is selected.
|
java.lang.String |
getSelectedItem()
Returns the caption of the selected button, or
null if no button is selected |
Control |
handleGeographicalFocusChangeKeys(KeyEvent ke)
Used by the main event loop to give the currently focused control an opportunity to act directly on
the KeyEvent.
|
protected void |
onBoundsChanged(boolean screenChanged)
Called after a setRect.
|
protected void |
onColorsChanged(boolean colorsChanged)
Called after a setEnabled, setForeColor and setBackColor and when a control has
been added to a Container.
|
void |
onEvent(Event event)
Called to process key, pen, control and other posted events.
|
protected void |
onFontChanged()
Called after a setFont
|
void |
onPaint(Graphics g)
Called to draw the control.
|
void |
setBorder(boolean border)
Sets the border.
|
void |
setColor(int index,
int foreColor,
int backColor)
Sets a button's index color.
|
void |
setCursorColor(int color)
Sets the cursor color for this PushButtonGroup.
|
void |
setHighlightColor(int highlightColor) |
void |
setHighlightEmptyValues(boolean highlightEmptyValues) |
void |
setHighlightSelected(boolean highlightSelected) |
void |
setNames(java.lang.String[] newNames)
Sets the names.
|
void |
setSelectedIndex(int ind)
Sets the selected button index.
|
void |
setSimpleBorder(boolean simple)
Uses a border with a single line (not 3d and not Android's)
|
_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, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isFloating, isInsideOrNear, isObscured, isTopMost, isVisible, isVisibleAndInside, 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, setEnabled, setFloating, setFocusLess, setFont, setForeColor, setNinePatch, setNinePatch, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
public static final byte NORMAL
public static final byte BUTTON
public static final byte CHECK
public boolean checkAppearsRaised
public java.lang.String[] names
public int insideGap
public Rect[] rects
public boolean autoRepeat
INITIAL_DELAY
,
AUTO_DELAY
public int INITIAL_DELAY
public int AUTO_DELAY
public boolean[] hidden
pbg.hidden[5] = true; // hides button 5 repaint();
public int[] colspan
String []numerics = {"1","2","3","4","5","6","7","clear",null,"0",null,null}; PushButtonGroup pbg=new PushButtonGroup(numerics,false,-1,4,0,4,true,PushButtonGroup.BUTTON); pbg.colspan[7] = 2; pbg.rowspan[7] = 2; add(pbg, LEFT+50,AFTER+50,FILL-50,FILL-50);... will show this:
1 2 3 4 5 6 7 clear 0
public int[] rowspan
String []numerics = {"1","2","3","4","5","6","7","clear",null,"0",null,null}; PushButtonGroup pbg=new PushButtonGroup(numerics,false,-1,4,0,4,true,PushButtonGroup.BUTTON); pbg.colspan[7] = 2; pbg.rowspan[7] = 2; add(pbg, LEFT+50,AFTER+50,FILL-50,FILL-50);... will show this:
1 2 3 4 5 6 7 clear 0
public PushButtonGroup(java.lang.String[] names, boolean atLeastOne, int selected, int gap, int insideGap, int rows, boolean allSameWidth, byte type)
names
- captions of the buttons. You can specify some names as null so the button is not displayed. This is good if you're creating a button matrix and want to hide some buttons definetively (you can hide some buttons temporarily setting the hiden array). You can also use the hidden
property to dynamically show/hide buttons.atLeastOne
- if true, at least one button must be selectedselected
- default index to appear selected, or -1 if nonegap
- space between the buttons, -1 glue them.insideGap
- Space between the text and the button border. The ideal is 4. If allSameWidth is true, it is only used to compute the preferred width and may be overriden; otherwise, it is used as the internal gap.rows
- if > 1, creates a button matrixallSameWidth
- if true, all the buttons will have the width of the most large one.type
- can be NORMAL, BUTTON or CHECKpublic PushButtonGroup(java.lang.String[] names, int gap, int rows)
names
- captions of the buttons. You can specify some names as null so the button is not displayed. This is good if you're creating a button matrix and want to hide some buttons definetively (you can hide some buttons temporarily setting the hiden array). You can also use the hidden
property to dynamically show/hide buttons.gap
- space between the buttons, -1 glue them.rows
- if > 1, creates a button matrixpublic PushButtonGroup(java.lang.String[] names, int gap, int insideGap, int rows)
names
- captions of the buttons. You can specify some names as null so the button is not displayed. This is good if you're creating a button matrix and want to hide some buttons definetively (you can hide some buttons temporarily setting the hiden array). You can also use the hidden
property to dynamically show/hide buttons.gap
- space between the buttons, -1 glue them.insideGap
- Space between the text and the button border. The ideal is 4. If allSameWidth is true, it is only used to compute the preferred width and may be overriden; otherwise, it is used as the internal gap.rows
- if > 1, creates a button matrixpublic void setBorder(boolean border)
border
- public void setNames(java.lang.String[] newNames)
public void setColor(int index, int foreColor, int backColor)
public void setSimpleBorder(boolean simple)
public int getSelectedIndex()
public java.lang.String getSelectedItem()
null
if no button is selectedpublic void setCursorColor(int color)
public int getPreferredWidth()
Control
getPreferredWidth
in class Control
public int getPreferredHeight()
Control
getPreferredHeight
in class Control
protected void onFontChanged()
Control
onFontChanged
in class Control
protected void onColorsChanged(boolean colorsChanged)
Control
onColorsChanged
in class Control
protected void onBoundsChanged(boolean screenChanged)
Control
onBoundsChanged
in class Control
screenChanged
- If the bounds were changed due to a screen change (rotation, collapse)public void onPaint(Graphics g)
Control
public int getEffectW()
getEffectW
in class Control
public int getEffectH()
getEffectH
in class Control
public int getEffectX()
getEffectX
in class Control
public int getEffectY()
getEffectY
in class Control
public void setSelectedIndex(int ind)
public void onEvent(Event event)
Control
public boolean getHighlightSelected()
public void setHighlightSelected(boolean highlightSelected)
public int getHighlightColor()
public void setHighlightColor(int highlightColor)
public boolean getHighlightEmptyValues()
public void setHighlightEmptyValues(boolean highlightEmptyValues)
public void clear()
public Control handleGeographicalFocusChangeKeys(KeyEvent ke)
Control
handleGeographicalFocusChangeKeys
in class Control
ke
- The KeyEvent to be processedSettings.geographicalFocus