I've implemented a custom button using the example code seen here, posted by Bikas: http://suppo开发者_开发问答rtforums.blackberry.com/t5/Java-Development/fixedwidth-buttonField-cannot-center-text/m-p/239116
However, I'd like for the button to look like the default Blackberry button.
How would I modify the paint method shown below to look like the default button?
protected void paint(Graphics graphics)
{
int w = width - (leftMargin + rightMargin);
int h = height - (topMargin + bottomMargin);
if(isFocus() == false)
{
graphics.setColor(backgroundColorNormal);
graphics.fillRoundRect(leftMargin, topMargin, w, h, 6, 6);
graphics.setColor(0x00394142);
graphics.drawRoundRect(leftMargin, topMargin, w, h, 6, 6);
graphics.drawText(label, labelTopLeftPoint.x, labelTopLeftPoint.y);
}
else
{
graphics.setColor(backgroundColorOnFocus);
graphics.fillRoundRect(leftMargin, topMargin, w, h, 6, 6);
graphics.drawRoundRect(leftMargin, topMargin, w, h, 6, 6);
graphics.setColor(0x00ffffff);
graphics.drawText(label, labelTopLeftPoint.x, labelTopLeftPoint.y);
}
}
I can't seem to find this information anywhere when searching.
Thank you for your help,
StatefulIn either Eclipse or the legacy JDE, add a unmodified ButtonField to your application, place a breakpoint after you have initialized the object and inspect the details of the unmodified ButtonField to get the properties you need.
精彩评论