2010-04-16 70 views
0

我有以下情况:如何在draw2d中垂直和水平放置标签图?

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(真/假)居中标签垂直或水平; ,但不在一起。任何想法如何使其工作?

+0

这应该被标记为SWT? – trashgod 2010-04-17 00:39:33

回答

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); 
0

我解决我的问题集中使用西蒙的回答标签名称。 Thx

setLayoutManager(new BorderLayout()); 
labelName.setTextAlignment(PositionConstants.CENTER); 
add(labelName, BorderLayout.CENTER); 
setBackgroundColor(ColorConstants.lightBlue);