自动换行的draw2d标签

在draw2d中跟文字布局相关的东西是Flow,无论是布局还是figure,都是FlowXX或者XXFlow。下面是八进制博客里面的代码:

class LabelEx extends FlowPage {

    private TextFlow contents;

    public LabelEx() {
        this("");
    }

    public LabelEx(String text) {
        contents = new TextFlow();
        contents.setLayoutManager(new ParagraphTextLayout(contents, ParagraphTextLayout.WORD_WRAP_SOFT));
        contents.setText(text);
        add(contents);
    }

    public void setText(String text) {
        contents.setText(text);
    }

    public String getText() {
        return contents.getText();
    }
}

猜你喜欢

转载自lengbingteng-163-com.iteye.com/blog/1423432