1

Rssファイルから LWUIT フォーム画面に表示されるタイトルと画像があります。-by-chen-fishbein.html )、しかし、問題は、画像とタイトルがフォーム画面に 1 行に並んで表示されるはずですが、Rss の一部のタイトルについては、並べて表示できないことです。画像を 1 行で表示でき、タイトルは 2 行目に表示されますか? ここに私のコード:

public class NewsListCellRenderer extends Container implements ListCellRenderer {
    private Label name = new Label("");
    private Label icon = new Label("");
    private Label focus = new Label("");
    public NewsListCellRenderer() {
    setLayout(new BorderLayout());
    Container cnt = new Container();      
    name.getStyle().setBgTransparency(0);
    name.getStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL));
    cnt.addComponent(icon);
    cnt.addComponent(name);
    addComponent(BorderLayout.CENTER, cnt);
    focus.getStyle().setBgTransparency(100);
    focus.getStyle().setBgColor(0xFFFFFF);
    }
public Component getListCellRendererComponent(List list, Object value, int i, boolean bln) {
     News news = (News) value;
     name.setText(news.getTitle().trim());
     icon.setIcon(news.geImage());
     this.getStyle().setBorder(Border.createLineBorder(1, 0x666666));     
      return this;
    }
4

1 に答える 1

2

問題は、名前とアイコンラベルの両方をコンテナ内に配置したことです。コンテナのレイアウトを設定していません。コンテナを使用する必要はありませんが、そのレイアウトを設定する必要がある場合。BorderLayoutのWESTまたはEASTに画像を配置してから、コンテナを中央に配置します。

setLayout(new BorderLayout());

Container cnt = new Container();
cnt.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

name.getStyle().setBgTransparency(0);
name.getStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL));

cnt.addComponent(name);

addComponent(BorderLayout.WEST, icon);
addComponent(BorderLayout.CENTER, cnt);
于 2012-08-30T15:56:22.570 に答える