Motorola T720 Developer's Manual page 46

Hide thumbs Also See for T720:
Table of Contents

Advertisement

/**
* gets the label
* @see setLabel
*/
public String getLabel() {
}
/**
* sets the label
* @see getLabel
*/
public void setLabel(String label) {
}
These methods, getLabel() and setLabel(), fetch the string that represents
the RoundButton's label or sets it, respectively.
The next method, paint(), contains the code that draws a round button:
/**
* paints the RoundButton
*/
// Ensure that the button doesn't draw into
// the clipping area
// Set the color, depending upon if button is depressed
The first section of code derives a value s that becomes the size of a rectangle within
which the LWT draws the round button. It takes the values that getWidth() and
getHeight() obtain for this component's dimensions, and uses the largest value.
46
return label;
this.label = label;
repaint();
public void paint(Graphics g) {
int s = Math.max(getWidth() - 5, getHeight() - 5);
if (hasFocus()) {
g.drawArc(0,0, s+4,s+4,0,360);
} //end if
if (isPressed()){
g.setColor(0, 0, 0);
} // end if
else {
g.setColor(220, 220, 220);
} // end else
// black, pressed state
// gray, normal state

Advertisement

Table of Contents
loading

Table of Contents