开发者

Blackberry custom button that looks like the default button

开发者 https://www.devze.com 2023-02-09 13:42 出处:网络
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-

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,

Stateful


In 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号