Copy and Paste JPanel custom component Netbeans 5.5

View: New views
8 Messages — Rating Filter:   Alert me  

Copy and Paste JPanel custom component Netbeans 5.5

by RichardF :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am suddenly getting 'errors occurred in loading the form data ... ' error message when i load a form. This error is then followed by 'error in loading component'  for each instance of a custom component - The form contains a couple of custom JPanel components that reside in the same package (I used the feature to copy from the component in project explorer and paste onto the form - which did work very nicely).

Anyway, I tried creating a new form and tried to add one of the custom components to it: the copy/paste method described above just does nothing.  And i tried adding the jar to the Palette but the wizard just says 'the selected JAR archive does not contain any JavaBeans components.'  I can't see anything wrong with these components and they both compile fine.


The only thing I can think of is by recreating each custom component and then the form - which is quite a lot of work.  

Any suggestions gratefully welcome.


(btw the project successfully compiles and is up-to date before i tried this).

Regards,
Rich.

Re: Copy and Paste JPanel custom component Netbeans 5.5

by JosiahHaswell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

RichardF wrote:

> Hi,
>
> I am suddenly getting 'errors occurred in loading the form data ... ' error
> message when i load a form. This error is then followed by 'error in loading
> component'  for each instance of a custom component - The form contains a
> couple of custom JPanel components that reside in the same package (I used
> the feature to copy from the component in project explorer and paste onto
> the form - which did work very nicely).
>
> Anyway, I tried creating a new form and tried to add one of the custom
> components to it: the copy/paste method described above just does nothing.
> And i tried adding the jar to the Palette but the wizard just says 'the
> selected JAR archive does not contain any JavaBeans components.'  I can't
> see anything wrong with these components and they both compile fine.
>
>
> The only thing I can think of is by recreating each custom component and
> then the form - which is quite a lot of work.  
>
> Any suggestions gratefully welcome.
>
>
> (btw the project successfully compiles and is up-to date before i tried
> this).
>
> Regards,
> Rich.
>
>  
Rich,

The Netbeans GUI builder won't load forms if they're not JavaBeans.  I
don't think it'll load any class that has arguments in the constructor,
or if it instantiates class variables in the constructor.  At least, you
have to be careful what happens in the constructor of a form.  Try
commenting out everything but the generated initComponent() method in
your constructor, remove all the arguments if there are any, and try
loading the form again.

Joe

Re: Copy and Paste JPanel custom component Netbeans 5.5

by Wade Chandler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

No, it should call the default constructor. You don't have to delete any code from it, but you have to be sure you have a default constructor and your bean isn't dependent upon parameters for it to be instantiated.

Wade
 
==================
Wade Chandler, CCE
Software Engineer and Developer, Certified Forensic Computer Examiner, NetBeans Dream Team Member, and NetBeans Board Member
http://www.certified-computer-examiner.com
http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org

----- Original Message ----
From: Josiah Haswell <josiah.haswell@...>
To: nbui@...
Sent: Wednesday, November 7, 2007 2:13:11 AM
Subject: Re: [nbui] Copy and Paste JPanel custom component Netbeans 5.5


RichardF wrote:
> Hi,
>
> I am suddenly getting 'errors occurred in loading the form data ... '
 error
> message when i load a form. This error is then followed by 'error in
 loading
> component'  for each instance of a custom component - The form
 contains a
> couple of custom JPanel components that reside in the same package (I
 used
> the feature to copy from the component in project explorer and paste
 onto
> the form - which did work very nicely).
>
> Anyway, I tried creating a new form and tried to add one of the
 custom
> components to it: the copy/paste method described above just does
 nothing.
> And i tried adding the jar to the Palette but the wizard just says
 'the
> selected JAR archive does not contain any JavaBeans components.'  I
 can't
> see anything wrong with these components and they both compile fine.
>
>
> The only thing I can think of is by recreating each custom component
 and
> then the form - which is quite a lot of work.  
>
> Any suggestions gratefully welcome.
>
>
> (btw the project successfully compiles and is up-to date before i
 tried
> this).
>
> Regards,
> Rich.
>
>  
Rich,

The Netbeans GUI builder won't load forms if they're not JavaBeans.  I
don't think it'll load any class that has arguments in the constructor,
 
or if it instantiates class variables in the constructor.  At least,
 you
have to be careful what happens in the constructor of a form.  Try
commenting out everything but the generated initComponent() method in
your constructor, remove all the arguments if there are any, and try
loading the form again.

Joe



Re: Copy and Paste JPanel custom component Netbeans 5.5

by Wade Chandler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Oh yeah, Richard, please post questions to nbusers instead of nbui. nbui is for discussing the actual user interface of NetBeans: IDE and RCP.

Thanks,

Wade
 
==================
Wade Chandler, CCE
Software Engineer and Developer, Certified Forensic Computer Examiner, NetBeans Dream Team Member, and NetBeans Board Member
http://www.certified-computer-examiner.com
http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org

----- Original Message ----
From: Josiah Haswell <josiah.haswell@...>
To: nbui@...
Sent: Wednesday, November 7, 2007 2:13:11 AM
Subject: Re: [nbui] Copy and Paste JPanel custom component Netbeans 5.5


RichardF wrote:
> Hi,
>
> I am suddenly getting 'errors occurred in loading the form data ... '
 error
> message when i load a form. This error is then followed by 'error in
 loading
> component'  for each instance of a custom component - The form
 contains a
> couple of custom JPanel components that reside in the same package (I
 used
> the feature to copy from the component in project explorer and paste
 onto
> the form - which did work very nicely).
>
> Anyway, I tried creating a new form and tried to add one of the
 custom
> components to it: the copy/paste method described above just does
 nothing.
> And i tried adding the jar to the Palette but the wizard just says
 'the
> selected JAR archive does not contain any JavaBeans components.'  I
 can't
> see anything wrong with these components and they both compile fine.
>
>
> The only thing I can think of is by recreating each custom component
 and
> then the form - which is quite a lot of work.  
>
> Any suggestions gratefully welcome.
>
>
> (btw the project successfully compiles and is up-to date before i
 tried
> this).
>
> Regards,
> Rich.
>
>  
Rich,

The Netbeans GUI builder won't load forms if they're not JavaBeans.  I
don't think it'll load any class that has arguments in the constructor,
 
or if it instantiates class variables in the constructor.  At least,
 you
have to be careful what happens in the constructor of a form.  Try
commenting out everything but the generated initComponent() method in
your constructor, remove all the arguments if there are any, and try
loading the form again.

Joe



Re: Copy and Paste JPanel custom component Netbeans 5.5

by Wade Chandler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

One more thing, you have to be sure if you have any 3rd party dependencies..runtime or compile time...they are on the projects classpath.

Wade
 
==================
Wade Chandler, CCE
Software Engineer and Developer, Certified Forensic Computer Examiner, NetBeans Dream Team Member, and NetBeans Board Member
http://www.certified-computer-examiner.com
http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org

----- Original Message ----
From: Wade Chandler <hwadechandler-nb@...>
To: nbui@...
Sent: Wednesday, November 7, 2007 7:54:37 AM
Subject: Re: [nbui] Copy and Paste JPanel custom component Netbeans 5.5


No, it should call the default constructor. You don't have to delete
 any code from it, but you have to be sure you have a default constructor
 and your bean isn't dependent upon parameters for it to be
 instantiated.

Wade
 
==================
Wade Chandler, CCE
Software Engineer and Developer, Certified Forensic Computer Examiner,
 NetBeans Dream Team Member, and NetBeans Board Member
http://www.certified-computer-examiner.com
http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org

----- Original Message ----
From: Josiah Haswell <josiah.haswell@...>
To: nbui@...
Sent: Wednesday, November 7, 2007 2:13:11 AM
Subject: Re: [nbui] Copy and Paste JPanel custom component Netbeans 5.5


RichardF wrote:
> Hi,
>
> I am suddenly getting 'errors occurred in loading the form data ... '
 error
> message when i load a form. This error is then followed by 'error in
 loading
> component'  for each instance of a custom component - The form
 contains a
> couple of custom JPanel components that reside in the same package (I
 used
> the feature to copy from the component in project explorer and paste
 onto
> the form - which did work very nicely).
>
> Anyway, I tried creating a new form and tried to add one of the
 custom
> components to it: the copy/paste method described above just does
 nothing.
> And i tried adding the jar to the Palette but the wizard just says
 'the
> selected JAR archive does not contain any JavaBeans components.'  I
 can't
> see anything wrong with these components and they both compile fine.
>
>
> The only thing I can think of is by recreating each custom component
 and
> then the form - which is quite a lot of work.  
>
> Any suggestions gratefully welcome.
>
>
> (btw the project successfully compiles and is up-to date before i
 tried
> this).
>
> Regards,
> Rich.
>
>  
Rich,

The Netbeans GUI builder won't load forms if they're not JavaBeans.  I
don't think it'll load any class that has arguments in the constructor,
 
or if it instantiates class variables in the constructor.  At least,
 you
have to be careful what happens in the constructor of a form.  Try
commenting out everything but the generated initComponent() method in
your constructor, remove all the arguments if there are any, and try
loading the form again.

Joe





Re: Copy and Paste JPanel custom component Netbeans 5.5

by RichardF :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Thanks for your responses.  Alas I have had no luck with any of your suggestions.

I ensured each custom component (there are 2) had a default constructor, with 1st line initComponents().

I even commented out all non generated code  (on both the custom components and the main dialog) (imports, interface implementations, methods etc).  Still i get no luck.

I have tried clean and build - still nothing.

I tried creating a new empty JFrame form and Ctrl-C/Ctrl-V from my custom components to the form - nothing happens.

Originally one of the components did have a custom constructor along with customized initialization code (see http://weblogs.java.net/blog/joshy/archive/2006/02/using_custom_sw.html). After i removed the custom constructor (although I had to edit the main dialog's .form file since i couldn't open the design to remove the 'custom creation code' and also removed the custom initialization code from the initComponents method using a text editor).  This still didn't fix it.


Eventually (and relucantly!) I re-created the components and GUI elements and then copied in the old code.

This worked and I was able to create a new dialog and copy and paste the components onto the dialog.

Regards,
Rich.


ps. Apologies posting to the wrong forum .....


Re: Copy and Paste JPanel custom component Netbeans 5.5

by Wade Chandler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Please describe the copy/paste some more. In NB, to use your components, all you should have to do is either 1) Install them to the Palette or (in 6.0) 2) Drag the components class from the project files window. Copy/paste should work fine while you are in a form and copy one UI item or a few and paste them to the same form. Were you trying to copy/paste between two forms and had problems? I'm not sure about that use case necessarily.

Wade


----- Original Message ----
From: RichardF <richy_french@...>
To: nbui@...
Sent: Friday, November 9, 2007 6:02:16 AM
Subject: Re: [nbui] Copy and Paste JPanel custom component Netbeans 5.5



Hi,

Thanks for your responses.  Alas I have had no luck with any of your
suggestions.

I ensured each custom component (there are 2) had a default
 constructor,
with 1st line initComponents().

I even commented out all non generated code  (on both the custom
 components
and the main dialog) (imports, interface implementations, methods etc).
 
Still i get no luck.

I have tried clean and build - still nothing.

I tried creating a new empty JFrame form and Ctrl-C/Ctrl-V from my
 custom
components to the form - nothing happens.

Originally one of the components did have a custom constructor along
 with
customized initialization code (see
http://weblogs.java.net/blog/joshy/archive/2006/02/using_custom_sw.html).
After i removed the custom constructor (although I had to edit the main
dialog's .form file since i couldn't open the design to remove the
 'custom
creation code' and also removed the custom initialization code from the
initComponents method using a text editor).  This still didn't fix it.


Eventually (and relucantly!) I re-created the components and GUI
 elements
and then copied in the old code.

This worked and I was able to create a new dialog and copy and paste
 the
components onto the dialog.

Regards,
Rich.


ps. Apologies posting to the wrong forum ..... :blush:


--
View this message in context:
 http://www.nabble.com/Copy-and-Paste-JPanel-custom-component-Netbeans-5.5-tf4761409.html#a13664898
Sent from the Netbeans - UI mailing list archive at Nabble.com.



Re: Copy and Paste JPanel custom component Netbeans 5.5

by hozefa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks! I have been having this problem for the past month. I checked all over netbeans bug site etc. but to no avail. Fortunately all I had to do was follow your advise and remove additional data from the constructor and just leave the initComponents(); statement