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