我的目标是让一个带有背景图像的按钮以及这些标签的ontop。 我想将标签放在按钮的中心,并垂直对齐它的文本。我希望该按钮可以扩展为标签中字符的数量。什么是用于构建这种类型的复合小部件的最佳类型的面板,因为我遇到了使用AbsolutePanel的问题,因为它不会随其子元素动态增长。动态定位GWT小部件
private PushButton button;
private Label label = new Label();
private AbsolutePanel panel = new AbsolutePanel();
private Image image = new Image("images/rectangle_blue.png");
public ExpandingRectangularButton(String text)
{
label.setText(text);
String width = "120px";
String height = "160px";
image.setWidth(width);
image.setHeight(height);
button = new PushButton(image);
panel.add(button, 0, 0);
panel.setWidth(width);
panel.setHeight(height);
initWidget(panel);
}
什么是在这种情况下使用的最佳类型的面板?我已经尝试过流动,水平和flextables,但我无法正确地将这些部件堆叠在彼此之上
您是否尝试过使用CSS来做到这一点..您可以保留图像为标签的bg,text-align:center – JAVAC