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 78935 - adding beans creates uncompilable code
Summary: adding beans creates uncompilable code
Status: RESOLVED DUPLICATE of bug 48288
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 5.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-22 21:16 UTC by jonks
Modified: 2006-08-31 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
This test case cannot be compiled (12.44 KB, application/octet-stream)
2006-08-24 05:39 UTC, jonks
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jonks 2006-06-22 21:16:41 UTC
Firstly, I'm not sure what module or component this bug belongs to so please
rellocate if needed.

DO NOT WRITE ANY CODE, just let NB do everything under the hood.

1. Create a new project called "MyProject".
2. Create a JFrame in that project. call the class "MyJFrame".
3. Create a JPanel in that project. call the class "MyJPanel".

(Note: the classes are in the "MyProject" package)

4. Build the project.
5. Open "palette manager"
6. Select "Add from project"
7. Select "MyProject" (i.e. this is the current project)
8. Select "MyJPanel".
9. Click finish.
10. Open "MyJFrame" in design mode.
11. drag and drop the "MyJPanel" bean into "MyJFrame".
12. try to compile "MyProject".
13. You will find that NB has created invalid code for the "MyJPanel"
declaration added to "MyJFrame".

You have to use an external editor to manually change this:

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private MyProject.MyJPanel panel1;
    // End of variables declaration//GEN-END:variables

to this:

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private MyJPanel panel1;
    // End of variables declaration//GEN-END:variables
Comment 1 Jan Stola 2006-08-23 14:17:07 UTC
I am sorry, I don't understand what is wrong with the described test case. I 
tried to reproduce the problem, but everything works fine. Why do you want to 
change
private MyProject.MyJPanel panel1;
to
private MyJPanel panel1;
MyJPanel is in MyProject package, as you wrote. So, this declaration is correct 
(it uses fully qualified name).
Comment 2 jonks 2006-08-24 05:39:38 UTC
Created attachment 33224 [details]
This test case cannot be compiled
Comment 3 jonks 2006-08-24 05:51:05 UTC
My steps were inaccurate in my initial report.
The key to reproducing the bug is to create a nested package, 
eg. bug78935test.broken.com

Where there is a frame, bug78935test.broken.NewJFrame, that contains [tries to!]
bug78935test.broken.com.NewJPanel

In this case the following code is automatically created in
bug78935test.broken.NewJFrame.java:

    private bug78935test.broken.NewJPanel newJPanel1;

The compiler emits:

C:\svnroot\Bug78935Test\src\bug78935test\broken\NewJFrame.java:78: cannot
resolve symbol

symbol  : class NewJPanel 

location: package broken

    private bug78935test.broken.NewJPanel newJPanel1;

C:\svnroot\Bug78935Test\src\bug78935test\broken\NewJFrame.java:30: cannot
resolve symbol

symbol  : class NewJPanel 

location: package broken

        newJPanel1 = new bug78935test.broken.NewJPanel();


It is fixable by manually changing
    private bug78935test.broken.NewJPanel newJPanel1;
to
    private broken.NewJPanel newJPanel1;

and
    newJPanel1 = new bug78935test.broken.NewJPanel();
to
    newJPanel1 = new broken.NewJPanel();
Comment 4 Jan Stola 2006-08-30 17:03:19 UTC
I am sorry, I still don't understand how to reproduce this issue. Could you, 
please, sketch the layout of your project and describe exact steps to reproduce?
Comment 5 jonks 2006-08-30 19:01:22 UTC
I think what is happening is that I am refactoring the project, but the
refactoring does not touch varaibles created by the form designer. Here is how
to reproduce...


I'm using using JDK 5.0 Update 8

1. Create a new "Java Application" project.
2. Name the project "bugtest". The projects source level is be 1.5.
3. In the projects "Source Packages" node, right-click the "bugtest" package and
create a new package called "bugtest.ui".
4. In the "bugtest.ui" package, right-click and select "New->JFrame Form". Call
the frame "myFrame".
5. In the "bugtest.ui" package, right-click and select "New->JPanel Form". Call
the frame "myJPanel".

You should have the following project structure

bugtest
       |--->Main.java
       |
       |--->ui
             |---->myJFrame.java
             |---->myJPanel.java
          


6. Build the project. It builds without error.
7. Now open up myJFrame.java in "design view", resize it to make it about 3
inches wider and taller.
8. Open the palette, right-click and select "Pallete Manager".
9. In Pallete Manager chose "Add from Project".
10. Navigate to the project "bugtest" and click "Next".
11. Select "myJPanel" and click next.
12. Select "Swing" (or any other category you have, it doesn't matter for this
bug), and click finish.
13. Close Palette Manager.
14. Drag and Drop the newly added "myJPanel" from the palette onto your
"myJFrame", which should be open in design view.
15. Save, and build. It builds without error.


16. In the projects "Source Packages" node, right-click the "bugtest.ui" package
and create a new package called "bugtest.ui.panels"
17. Drag and drop "myJPanel.java" from the "bugtest.ui" pacakge into the
"bugtest.ui.panels" package.
18. In the 'Refactoring' dlg make sure that 'Move without refactoring' is
UNCHECKED and click Next.


You should have the following project structure

bugtest
       |--->Main.java
       |
       |--->ui
             |---->myJFrame.java
             |
             |---->panels
                         |---->myJPanel.java

19. Save, and build. It builds with the compile errors described in my earlier
bug report.
(the myJPanel references in myJFrame have not been refactored)


So the bug IS NOT in the form designer, but in the refactoring.


The only workarounds I have found are to either 
a) manaully edit the java files in an external text editor
b) i>   delete the myJPanel bean from the myJFrame in design mode, 
   ii>  delete the myJPanel bean the palette, 
   iii> rebuild the project, 
   iv>  recreate the myJPanel bean in the palette
   v>   drag and drop the myJPanel bean back onto the myJFrame.




Comment 6 Jan Stola 2006-08-31 09:14:16 UTC

*** This issue has been marked as a duplicate of 48288 ***