This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | GUI builder doesn't handle icon paths correctly | ||
---|---|---|---|
Product: | guibuilder | Reporter: | vbeffa <vbeffa> |
Component: | Code | Assignee: | issues@guibuilder <issues> |
Status: | NEW --- | ||
Severity: | blocker | ||
Priority: | P3 | ||
Version: | 6.x | ||
Hardware: | Macintosh | ||
OS: | Mac OS X | ||
Issue Type: | DEFECT | Exception Reporter: |
Description
vbeffa
2009-09-10 14:29:07 UTC
Reassigning. If you have your icon in Source Packages of your project then you should select it in 'Image Within Project' section of the icon property editor. The generated code with resource-name starting with slash ("/") should be correct e.g. it should be absolute resource-name of your icon. For example, if your icon is called icon.png and is located in com.myproject.resources then the resource-name should be "/com/myproject/resources/icon.png". Is the resource-name of your icon correct? Have you rebuilt (e.g. invoked Clean & Build) the whole project when you've added the icon? I've noticed you mentioned the generated code example:
> new javax.swing.ImageIcon(getClass().getResource("/image.tiff"))
Looks like the image was in the default package (i.e. no package). That would cause problems when trying to access via
a resource name. Please make sure the image is under some package.
Yes, the image name is correct. Currently it's in my src directory. I select the icon property of the button, then on the dialog select "Image Within Project," then the file chooser ("...") button. A second dialog comes up. It has 5 entries: Classpath, three jars in my project's lib folder (all with the path "/User/..."), and Source Packages. I expand Source Packages, it's empty. I type the image name manually. When I type it the OK button becomes enabled. I click OK but on the first dialog nothing has changed. I try the same thing with External Image. Bring up the file chooser. Select "All Files" from the pull-down because my images is a tiff. Select it from my src directory and click OK. Now the File or URL: field says "file:/Users/vbeffa/NetBeansProjects/Mailer/src/TB_New.tiff". It shows up in my GUI builder, and also in Preview Design. However, after a clean and build, when I run the project the button doesn't have the image as its icon. > because my images is a tiff
I didn't pay attention to the extension of your icon before, but now I see that it is the root of your 'Image Within
Project' part of the problem. I am able to reproduce it now. It seems that icon chooser wasn't designed with .tiff
extension in mind.
Unfortunately, I am still not able to reproduce the 'External Image' part. It works correctly on my machine, but I am
using Windows and I don't have access to Mac today. So, it may be Mac-specific. I will try it on Mac next week. Could
you, please, check the generated code in this case. It seems that there's something wrong with it, maybe the initial
slash that you mentioned in the first comment. Does the name of the file (in the generated code) start with the initial
slash? Does it work if your try to run the same code with the initial slash removed/added? Thank you in advance.
No, the external image path is correct, so I'm not sure why it doesn't work. On my Mac it's /Users/vbeffa/NetBeansProjects/Mailer/src/TB_AddressBook.tiff There are no error messages in the system console, or reported Java exceptions, so I'm not sure what is happening. |