2010-10-19 76 views
0

我需要制作一个圆形按钮,其上有一些文字(居中)。 对于圆形按钮,我使用的是Image和onClick方法,但是当我尝试在图像上重叠一些文本(居中)时,我的问题就出现了。GWT Button(Image + Text)

“像这样” alt text

文本必须是定制的,所以我不能只是让以前

图像的该怎么做任何提示吗?

在此先感谢。

回答

2

您也可以做到这一点使用了CSS

Button b = new Button("Calcular"); 
b.setPixelSize(200, 127); 
DOM.setStyleAttribute(b.getElement(), "background", "transparent url('http://www.greenthumbgraphics.com/images/buttons/shapes/oval.png')"); 
DOM.setStyleAttribute(b.getElement(), "border", "solid 0px white"); 
DOM.setStyleAttribute(b.getElement(), "textAlign", "center"); 
RootPanel.get().add(b); 

,但有一个问题,点击按钮,即使在透明区域合作。此外,如果您在鼠标悬停和mousedown上查找不同的图像,则使用CustomButton是更好的选择。