自动换行的draw2d标签

Draw2D里的Label不支持自动换行,虽然可以插入换行符手动换行。用TextFlow和适当的Layout可以实现文字的自动换行。以下代码由sean朋友贡献,原文链接

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();
    }
}

117 thoughts on “自动换行的draw2d标签

  1. Pingback: wwin-tv.com
  2. Pingback: 1 2 3 4 5 6 7 8 9 10
  3. Pingback: Video
  4. Pingback: 2020
  5. Pingback: HD-720
  6. Pingback: ++++++
  7. Pingback: watch
  8. Pingback: 匿名
  9. Pingback: +1+
  10. Pingback: 00-tv.com
  11. Pingback: serialy
  12. Pingback: tureckie_serialy
  13. Pingback: hs;br
  14. Pingback: we-b-tv.com
  15. Pingback: y3 sock wedge runner
  16. Pingback: monday shoes

发表评论