2010-04-16 47 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); 
相關問題