Ecarrion
Ecarrion

Reputation: 4950

GWT Button(Image + Text)

I need to make a round button with some text on it (Centered). For the round button, I'm using an Image and onClick methods, but my problems come when i'm trying to overlap some text (Centered) over the image.

"Like this "alt text

The text have to be customizable, so I can't just make the image previously

Any hints of how to do that?

Thanks in advance.

Upvotes: 0

Views: 3737

Answers (1)

Gaurav Saxena
Gaurav Saxena

Reputation: 4297

You can also achieve this using a bit of 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);

But there is a problem, button clicks work even in the transparent areas. Also, if you are looking for different images on mouseover and mousedown, then using CustomButton is a better option.

Upvotes: 2

Related Questions