EasyManua.ls Logo

Motorola T720 - Page 46

Motorola T720
57 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
46
/**
* gets the label
* @see setLabel
*/
public String getLabel() {
return label;
}
/**
* sets the label
* @see getLabel
*/
public void setLabel(String label) {
this.label = label;
repaint();
}
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
*/
public void paint(Graphics g) {
// Ensure that the button doesn't draw into
// the clipping area
int s = Math.max(getWidth() - 5, getHeight() - 5);
if (hasFocus()) {
g.drawArc(0,0, s+4,s+4,0,360);
} //end if
// Set the color, depending upon if button is depressed
if (isPressed()){ // black, pressed state
g.setColor(0, 0, 0);
} // end if
else { // gray, normal state
g.setColor(220, 220, 220);
} // end else
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.

Other manuals for Motorola T720

Related product manuals