0

我有以下情况:

Label label = new Label();
label.setText("bla");
RoundedRectangle fig = new RoundedRectangle();
fig.add(label);
FlowLayout layout = new FlowLayout();
layout.setStretchMinorAxis(true);
fig.setLayoutManager(layout);
fig.setOpaque(true);

这仅适用于使用 layout.setHorizo​​ntal(true/false); 使标签垂直或水平居中。,但不在一起。知道如何使它工作吗?

4

2 回答 2

1

尝试这样的事情:

Label label = new Label();
label.setText("bla");
label.setTextAlignment(PositionConstants.CENTER);

RoundedRectangle fig = new RoundedRectangle();    
fig.setLayoutManager(new BorderLayout());
fig.add(label, BorderLayout.CENTER);
于 2010-06-04T05:01:53.543 回答
0

我使用西蒙的答案解决了集中标签名称的问题。谢谢

setLayoutManager(new BorderLayout());
labelName.setTextAlignment(PositionConstants.CENTER);
add(labelName, BorderLayout.CENTER);
setBackgroundColor(ColorConstants.lightBlue);
于 2016-12-21T03:26:27.853 回答