Thursday, September 23, 2010

Re: PushButton text with HTML Elements

On Sep 23, 10:36 am, Kurcob <roggepatr...@googlemail.com> wrote:
> Hi Guys,
>
> so, in fact i have a problem with the PushButton and HTML elements.
> I try something like this:
>
> String text = "Hello World";
> String label = "<b>"  + text+ "</b>";
> PushButton b = new PushButton();
> b.setText(new HTML(l).toString());

Wow! new HTML(l).toString() ?!

> ....
>
> Browser Result:
> <b>Hello World</b>
>
> But i just want to see the text in bold style, but not with the HTML
> tags.
>
> So, knows anybody about a workaround or is there just no possibility
> to style text in a PushButton?

Just use setHTML instead of setText:
b.setHTML("<b>Hello world</b>");

But really, if all you want is bold text, you'd rather make a CSS rule
with a class selector and addStyleName() it:
CSS:
.myButton { font-weight: bold; }
Java:
b.addStyleName("myButton");
or if you want *all* your buttons to have a bold face, just
define .gwt-PushButton to be bold:
.gwt-PushButton { font-weight: bold; }

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment