Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Question about Button clases setIcon() method

    Hey, maybe someone can answer this rather quick answer - the guides didn't...
    smartGWT has various button classes like Button, IButton, ToolStripButton etc, all of which have a setIcon method.

    Could someone tell me
    1) if the Icon resource should be under the IsomorphicDir (default is SC) and the path can be relative ie "icons\printer.png" which would point to %DISK_PATH_TO_SC%\sc\icons\print.png
    2) what formats are "OK"? *.ico, *.png (examples usually feature PNG) and in what sizes (though it should be alright to have any kind of size, I think (just button properties should be set accordingly).

    1 is kinda vital, 2nd one I think i can realize myself, putting it here for reference purposes, maybe someone else will be interested in this :)

    #2
    1) It should be in your own images directory, whether that is called images/ or icons/ or whatever. Generally there is a single directory (which can contain many subdirectories) with all your web app images. It does not need to be in the SC directory.

    2) The buttons come with default widths and heights, so having icons of different sizes is ok, but you will need to either change the height and/or width or use autoHeight() and authWidth() on the buttons. Formats should be png or gif, those are generally the agreed upon norms for the web.

    Comment


      #3
      So regarding one in my project folder (Eclipse project) I should have an Icon directory with the icons and then access it via a relative path, ie:
      mButton.setIcon("images/back.png");

      Correct? Guess I will just ahve to do a little trial and error to realise how Eclipse picks up the relative paths :)

      Comment


        #4
        Correct, also look into setAppImageDir(), if you need to use multiple locations. This isn't an Eclipse thing as much as a general web app thing.

        Comment


          #5
          svajrd, I'm still having an issue.

          Let's say my Eclipse workspace has a proejct MyProject in it, the MyProject folder has a subdir - Icons which has various PNG files (24x24 in size).

          In code I do:
          ToolStripButton btnPrint = new ToolStripButton();
          btnPrint.setPrompt("Print");
          btnPrint.setIcon("Icons/PNG-24/Print.png"); //Assuming the root dir is the project dir
          btnPrint.setAutoWidth();
          btnPrint.setAutoHeight();

          The image doesn't render on the button. I see the button taking the dimensions of the picture, but the image itself does not appear.

          It's either I have a bad image or the relative path is not correct... Any hints?

          Comment


            #6
            well first thing is try an image from the smartgwt showcase, so your 100% sure nothing wrong with the image file. The second thing is Icons/ under WEB-INF? Generally going to be harder to debug in Eclipse, whereas in a browser you can apply firebug or chrome util to see where it is looking for to find the image.

            Comment


              #7
              Thanks for the tips, I will remember that web apps need to have the resources in WEB-INF at all times. However I think the problem might be that I'm deploying it to Google AppEngine for testing and the process of deploying on appengine might not copy over the icons I'm using.

              Comment


                #8
                Turned out to be trivial, the Icons should've been placed not into WEB-INF but into war/images/ directory.

                Comment

                Working...
                X