Thursday, January 26, 2012

Re: HELP.. ADDING IMAGE TO PushButton.

First put your image to war/images folder and then direct access it
from ur code like this
HTML html = new HTML(new Image("images//Image_Name.png").toString());
Button button = new Button(h.toString());

now u can do ur work

On Jan 24, 10:50 am, Joshua Carey <jc11...@gmail.com> wrote:
> Hi,
>
> I am new to GWT but been developing java for a few years.  I am trying to
> add a simple png ICON to a button and in GWT I guess PushButton is the only
> widget to use.  I am not concerned with changing the image when the button
> is pressed, etc.  I simply want a default image to always display on the
> button.  I have tried putting the image file in the same directory as the
> war file, but that didn't work.  I also tried putting it in subdirectories
> throughout the project paths with still no luck.  A coworker told me that
> images must be in WEB-INF or a subdirectory of WEB-INF.  I c created a
> directory under WEB-INF called "IMG":
>
> WEB-INF/img/printer_image.png.  In my java code I used the following logic
> and it still doesn't work.  I really need some direction here and
> appreciate any help anyone can provide.  Thank you very much.
>
> //Image printImage = new
> Image("/tomcateomconsole/webapps/pdficon_large.png");   "This image path is
> where the War is deployed and didn't work".
>
> Image printImage = new Image("/WEB-INF/img/pdficon_large.png");   "This
> image path is under the WEB-INF and gets deployed with the war file but
> still doesn't work.
>
> PushButton printButton = new PushButton(printImage);
>
> Joshua

--
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