在黑莓的圆形按钮厚边框 [英] Thick border for rounded button in blackberry

查看:186
本文介绍了在黑莓的圆形按钮厚边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


   我得到这个......我想下面的图片
我在黑莓newbee。

I am getting this... I want the below image I am newbee in Blackberry.

我想给粗边框的圆角按钮场我的申请。

I want to give thick border to the rounded button field in my application.

下面是我的code。

我创建了一个CustomBasicEditField类。

I have created a CustomBasicEditField class.

protected void paint(Graphics graphics)
{

    int x = (this.getWidth() - getFont().getAdvance(text)) >> 1;
    int y = (this.getHeight() - getFont().getHeight()) >> 1;

    graphics.setColor(backgroundColour);
    graphics.fillRoundRect(0, 0, fieldWidth, fieldHeight, 40, 40);
    graphics.setColor(border_color);
    graphics.setStrokeWidth(5);
    graphics.drawRoundRect(0, 0, fieldWidth, fieldHeight, 40, 40);
    graphics.setColor(0x2bb1ff);
    graphics.setFont(myFont);
    graphics.drawText(text, x, y);

    super.paint(graphics);
}

如果我做drawRoundRect(0,0,fieldWidth,fieldHeight,0,0),然后将它打印带有粗边框的正方形。

If I make drawRoundRect(0,0,fieldWidth, fieldHeight, 0, 0), then it prints a square with thick border.

但我不想要一个正方形。当我把上面的code,它创建一个圆形的编辑框,但细边框。

But I don't want a square. When I keep the above code, it does create a rounded edit box but a thin border.

先谢谢了。

推荐答案

试试这个code:

public class LoadingScreen extends MainScreen
{       
ButtonField save;
public LoadingScreen()
{   
    setTitle("Loading Screen");
    createGUI();
}

private void createGUI() 
{
    VerticalFieldManager vr=new VerticalFieldManager();
    Border border=BorderFactory.createRoundedBorder(new XYEdges(5,5,5,5),Color.RED,Border.STYLE_FILLED);
    // give XYEdges(10,10,10,10) and see the difference;        
    save=new ButtonField("Save");       
    save.setBorder(border);     
    vr.add(save);
    vr.setPadding(5, 5, 5, 5);
    add(vr);
}

public boolean onMenu(int instance) 
{
    return true;
}
}

我是这样的:

这篇关于在黑莓的圆形按钮厚边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆