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.

Bug 121667 - Problem with palette custom components when a class name is the same as the package name
Summary: Problem with palette custom components when a class name is the same as the p...
Status: RESOLVED INVALID
Alias: None
Product: ide
Classification: Unclassified
Component: Code (show other bugs)
Version: 5.x
Hardware: All All
: P4 blocker (vote)
Assignee: issues@ide
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-10 21:56 UTC by scarpent
Modified: 2007-11-14 10:07 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Sample project demonstrating problem. (13.80 KB, application/x-gzip)
2007-11-10 21:58 UTC, scarpent
Details

Note You need to log in before you can comment on or make changes to this bug.
Description scarpent 2007-11-10 21:56:53 UTC
I'm new to NetBeans and Java GUI programming, so I hope this really is a defect.  I've found that having a class with
the same name as a package causes problem in Matisse when using custom components in the palette.

I have reproduced a simple case with:

package Example, having:

Example.java
ExampleUI.java  (form, extends JFrame)
labelExample.java (extends JLabel)

Adding labelExample to the palette and then dragging on to the ExampleUI form causes an error on the variable
declaration (and in initComponents).  The generated declaration:

private Example.labelExample labelExample1;

shows red to indicate an error, which is:

cannot find symbol
symbol: class labelExample
location: class Example.Example

I think the hint is in the location. If I rename Example.java to something other than the package name, it works fine.

I'll attached a .tgz file with the example project.
Comment 1 scarpent 2007-11-10 21:58:58 UTC
Created attachment 52840 [details]
Sample project demonstrating problem.
Comment 2 scarpent 2007-11-10 22:10:37 UTC
Also, declaring in ExampleUI:

private labelExample labelExample2;

Doesn't cause any complaint.  And now it occurred to me to try a plain old class that doesn't extend anything, and:

private Example.Banana abc;

Causes the same problem.  So it's not really palette/component related at all, it's just that I struggled so long with
it in that area that I was fixated on it as a palette custom component problem.

Apparently NetBeans is just confused when a class name is the same as the package name, and you refer to any class with
the fully qualified path.

Comment 3 scarpent 2007-11-10 22:19:13 UTC
And!  It makes sense, since how should the IDE know if you're referring to the package or the class, and it wouldn't be
a problem except that you can't change the declaration generated by the GUI builder, so you're kind of stuck with having
the ambiguous "Example" in there. (As far as I can tell.)
Comment 4 ehucka 2007-11-14 08:32:08 UTC
Try to compile your project with javac outside the IDE. It throws the same errors like the ide. So it is not probably
issue on our side.
Comment 5 scarpent 2007-11-14 10:07:35 UTC
I figured out in the course of filing this report that the behavior is valid, although I still think there is a small
issue in that the IDE won't let you change your declaration to something that works.  But knowing better now I wouldn't
name one of my classes the same as the package.  But, thanks, and sorry for false accusations. :-)