Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ve-dev] Setting images in the Eclipse view(Swing components)


Hi,

For the future questions on how to use the VE or coding questions like this should be asked on the eclipse.tools.ve  newsgroup. This mailing list is for VE developer/extenders discussions of extending the VE or developing the VE itself.




"H Ramachandra, Rashmi" <rashmi.h.ramachandra@xxxxxxx>
Sent by: ve-dev-bounces@xxxxxxxxxxx

01/31/2006 02:06 AM

Please respond to
Discussions people developing code for the Visual Editor project <ve-dev@xxxxxxxxxxx>

To
<ve-dev@xxxxxxxxxxx>
cc
Subject
[ve-dev] Setting images in the Eclipse view(Swing components)





Hi all ,
  I have created a view in Eclipse. That uses a JTree(Swing) and  Toolbar  menu(Swing JButton component used) embedded inside swt composite. I am trying to set images to the toolbar buttons and the tree node. The images are included under /icons directory in the same directory where the class file exists.The code I used is

        Button.setIcon(new ImageIcon("/icons/toolbarimages/forward.gif"));

--- RLK -- This will not retrieve files out of the classpath but instead of the current directory. Those are not the same thing.


The path is correct but I am unable to load the image. The images are not visible.

I tried giving the path from the plugin root and placing the icons folder under the plugin directory as below.

     

  Button.setIcon(new ImageIcon("platform:/plugin/'PluginName'/images/toolbarimages/forward.gif"));

--- RLK -- Again this won't work because this is the format of a URL, but you are using the String filename format, not a URL.

--- RLK --- Now let's use the following example where this is your classpath structure

com/

  xyz/

    MyButton.class

    icons/

      toolbarimages/

        forward.gif

This is what your code should look like:

        button.setIcon(new ImageIcon(MyButton.getClass().getResource("icons/toolbarimages/forward.gif"));

Note that there is no leading '/' in the getResources because the icons are located relative to MyButton.class.

 

I am still unable to load the images . Can anybody please help.

Thank You and Best Regards,
Rashmi H.Ramachandra
_______________________________________________
ve-dev mailing list
ve-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ve-dev


Back to the top