|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--waba.ui.Control | +--waba.ui.Button
Button is a push button control.
Here is an example showing a push button being used:
public class MyProgram extends MainWindow { Button pushB; public void onStart() { add(pushB = new Button("Push me"), CENTER,TOP); // PS: you can also create an image button with pushB = new Button(new Image("myimage.bmp")); } public void onEvent(Event event) { if (event.type == ControlEvent.PRESSED && event.target == pushB) { ... handle pushB being pressed
Field Summary | |
protected Color |
aColor
|
protected boolean |
armed
|
protected byte |
border
|
static byte |
BORDER_3D
|
static byte |
BORDER_NONE
|
static byte |
BORDER_SIMPLE
|
static int |
commonGap
Set commonGap to a value to make all further buttons with the same internal gap. |
protected Color |
fColor
|
protected Color[] |
fourColors
|
protected int |
gap
|
protected int |
hh
|
protected boolean |
ignoreEvents
|
protected Image |
img
|
protected Color |
imgColor
|
protected boolean |
isText
|
protected Graphics |
myg
|
protected String |
text
|
protected int |
ww
|
Fields inherited from class waba.ui.Control |
AFTER,
appId,
asContainer,
asWindow,
backColor,
backDis,
BEFORE,
BOTTOM,
CENTER,
enabled,
FILL,
FIT,
fm,
fmH,
focusLess,
font,
foreColor,
foreDis,
height,
LEFT,
parent,
PREFERRED,
RANGE,
RIGHT,
SAME,
TOP,
visible,
width,
x,
x2,
y,
y2 |
Constructor Summary | |
Button(Image img)
Creates a button with the given image. |
|
Button(String text)
Creates a button displaying the given text. |
Method Summary | |
static Button |
createArrowButton(byte type,
int h,
Color fore)
just a handy method to create buttons with an arrow drawed. |
Image |
getImage()
Returns the image that is assigned to this Button |
int |
getPreferredHeight()
returns the preffered height of this control. added by guich |
int |
getPreferredWidth()
returns the preffered width of this control. added by guich |
String |
getText()
Gets the text displayed in the button. |
protected void |
onBoundsChanged()
Called after an 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 by the system to pass events to the button. |
protected void |
onFontChanged()
Called after a setFont |
void |
onlyShowImage()
Make this button act like an image control. |
void |
onPaint(Graphics g)
Called by the system to draw the button. it cuts the text if the button is too small. |
protected void |
paintButton(Graphics g,
boolean armed)
|
void |
press(boolean pressed)
simulate the press or release of this button. does not generate events |
void |
setBorder(byte border)
Sets the style of the border. use the constants BORDER_xxx |
void |
setGap(int gap)
Sets the gap between the text/image and the border. |
void |
setText(String text)
Sets the text that is displayed in the button. |
Methods inherited from class waba.ui.Control |
addTimer,
contains,
createGraphics,
getAbsoluteRect,
getBackColor,
getFont,
getFontMetrics,
getForeColor,
getNext,
getParent,
getParentWindow,
getPos,
getRect,
getSize,
isDisplayed,
isEnabled,
isVisible,
onWindowPaintFinished,
postEvent,
removeTimer,
repaint,
repaintNow,
requestFocus,
setBackColor,
setBackForeColors,
setEnabled,
setFocusLess,
setFont,
setForeColor,
setRect,
setRect,
setRect,
setVisible |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
toString,
wait,
wait |
Field Detail |
public static final byte BORDER_NONE
public static final byte BORDER_SIMPLE
public static final byte BORDER_3D
protected String text
protected Image img
protected boolean armed
protected boolean isText
protected int gap
protected byte border
protected int ww
protected int hh
protected Color fColor
protected Color imgColor
protected Color aColor
protected Graphics myg
protected Color[] fourColors
protected boolean ignoreEvents
public static int commonGap
setGap
method.
Note that this value will be added to the value of gap
.
Remember to save the current value and restore it when done.Constructor Detail |
public Button(String text)
public Button(Image img)
Method Detail |
public void setText(String text)
public void onlyShowImage()
public void setBorder(byte border)
public void setGap(int gap)
public String getText()
public int getPreferredWidth()
public int getPreferredHeight()
public void onEvent(Event event)
event
- the event to processEvent
,
KeyEvent
,
PenEvent
public void press(boolean pressed)
public void onPaint(Graphics g)
g
- the graphics object for drawingGraphics
protected void onFontChanged()
protected void onBoundsChanged()
protected void onColorsChanged(boolean colorsChanged)
protected void paintButton(Graphics g, boolean armed)
public static Button createArrowButton(byte type, int h, Color fore)
byte
- Graphics.ARROW_UP or Graphics.ARROW_DOWN or Graphics.ARROW_LEFT or Graphics.ARROW_RIGHTh
- same of Graphics.drawArrowfore
- the foreground color for the arrow. the background color will be the required transparent color.Graphics.drawArrow(int, int, int, byte, boolean, boolean, Color)
public Image getImage()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |