本文介绍了黑莓 - 如何添加边框BasicEditField?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用BasicEditField在我的黑莓程序中,BasicEditField亘古不显示任何border.So我想自定义BasicEditField与border.please显示给一些code片段。

I used BasicEditField in my Blackberry program,the BasicEditField doesnot display any border.So i want to customize the BasicEditField to display with border.please give some code snippets.

推荐答案

如果是4.6 RIM OS,你为什么不使用的:

If it's 4.6 RIM OS, why don't you use Border:

BasicEditField roundedBorderEdit = new BasicEditField();
XYEdges padding = new XYEdges(15, 15, 15, 15);
int color = Color.CRIMSON;
int lineStyle = Border.STYLE_DOTTED;
Border roundedBorder = BorderFactory.createRoundedBorder(padding,
     color, lineStyle);
roundedBorderEdit.setBorder(roundedBorder);

BasicEditField bevelBorderEdit = new BasicEditField();
XYEdges edges = new XYEdges(10, 10, 10, 10);
XYEdges outerColors = new XYEdges(Color.BLACK, Color.WHITE,
     Color.BLACK, Color.WHITE);
XYEdges innerColors = new XYEdges(Color.WHITE, Color.BLACK,
     Color.WHITE, Color.BLACK);
Border bevelBorder = BorderFactory.createBevelBorder(edges,
     outerColors, innerColors);
bevelBorderEdit.setBorder(bevelBorder);

如果您的BlackBerry OS 4.5版及以上的,你可以尝试绘制位图与它接壤,油漆事件:

If your BlackBerry OS version 4.5 and older, you may try draw bitmap with border on it, on paint event:

class BorderedEdit extends BasicEditField
{
    Bitmap mBorder = null;

    public BorderedEdit(Bitmap borderBitmap) {
    	mBorder = borderBitmap;
    }

    protected void paint(Graphics graphics) {
    	graphics.drawBitmap(0, 0, mBorder.getWidth(),
    	    mBorder.getHeight(), mBorder, 0, 0);
    	super.paint(graphics);
    }
}

这篇关于黑莓 - 如何添加边框BasicEditField?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-03 15:46