0

私は BB 画面にリスト項目 (画像とテキスト) を持っています。私の要件は、BB 画面の画像に画像の境界線を設定することです (リスト項目で画像の分離が行われるように)。

ここに私のコード:

public void drawListRow(ListField list, Graphics g, int index, int y,
            int width) {
        String title = (String) listElements.elementAt(index);

        Bitmap image = (Bitmap) listImage.elementAt(index);


            int LEFT_OFFSET = 2;
            int TOP_OFFSET = 8;
            int xpos = LEFT_OFFSET;
            int ypos = TOP_OFFSET + y;
            int w = image.getWidth();
            int h = image.getHeight();      

            g.drawBitmap(xpos, ypos, w, h, image, 4, 6);

            xpos = w + 20;
            g.setFont(myFont);

            g.setColor(Color.BLACK);

            g.drawText(title, xpos, ypos);

}
4

1 に答える 1

1

私はあなたの質問が正しいことを願っています、そしてあなたがそのように画像の周りに長方形を描くことを提案するでしょう:

g.setColor(Color.RED);
g.drawRect(xpos - 1, ypos - 1, w + 1, h + 1);

これにより、画像を重ねることなく、画像の周りに長方形が描画されます。長方形の位置とサイズのこれらの調整が必要な理由の詳細については、グラフィックスクラスのドキュメントをここで確認できますhttp://www.it.uc3m.es/florina/docencia/j2me/midp/docs/ api / javax / microedition / lcdui / Graphics.html

于 2013-03-06T10:52:35.847 に答える