NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

New JavaBeans Component vs. New JPanel Form and the "Design" pane

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
wahoodoss



Joined: 13 Mar 2012
Posts: 3

PostPosted: Wed Mar 14, 2012 12:13 am    Post subject: New JavaBeans Component vs. New JPanel Form and the "Design" pane Reply with quote

Hi Everyone!!

I'm a newbie to the NetBeans IDE; I've usually used Eclipse. I switched to NetBeans because I like its GUI builder versus the WindowBuilder Pro plugin for Eclipse.

I'm also a newbie to Java Beans; I fiddled with them a long while back but I have forgotten everything.

Because of the above constraints, I fear my question might be quite basic but a quick search with Mr. Google didn't help.

Here goes ... I'm starting a new project. I want to create some custom panels that will be reusable and that I can place on the GUI widget palette. If I create a "New JPanel Form ..." I can use the GUI builder "Design" workspace. But then I have to add the "implements Serializable".

If I create a "New JavaBeans Component ...", I get a Java Beans template but I have to add "extends JPanel". Also I don't get a GUI builder design workspace so I have to build the GUI by hand.

I'm sure I'm missing something fundamental here but I'm confused about what is the difference in the two approaches. Do my custom Panels have to be "beans" to go on the GUI palette? Are they already beans because they extend JPanel? Is there a good tutorial/article that would explain this for me?

Thanks times infinity!!
Bill
Back to top
Chuck Davis
Posted via mailing list.





PostPosted: Wed Mar 14, 2012 2:56 pm    Post subject: New JavaBeans Component vs. New JPanel Form and the "Design" pane Reply with quote

Bill, why do you think you have to add the Serializable interface to
your JPanel? Are you going to try to send your JPanel across a wire?
If so, why?

Tell us more about what you're thinking. Just create a JPanel,
compile and add to your palette manager. Why does this not work for
you?

Chuck





On Tue, Mar 13, 2012 at 5:14 PM, wahoodoss <address-removed> wrote:
Quote:
Hi Everyone!!

I'm a newbie to the NetBeans IDE; I've usually used Eclipse.
Back to top
wahoodoss



Joined: 13 Mar 2012
Posts: 3

PostPosted: Thu Mar 15, 2012 3:54 pm    Post subject: Reply with quote

Hey Chuck, thanks for helping.

I think my confusion results because of a not complete understand of just what is a "Java Bean" and because I thought that in order to place a custom component, i.e. user created subclass of a standard component, on the palette it had to be a bean. [Note: I know how to add a custom widget to the palette; I was able to figure that one out . Smile]

Think that it had to be a "bean", the first custom panel that I created, I started as a "New | JavaBeans Component", which gave me :

Code:

public class MyFirstPanel implements Serializable {


along with the "propertySupport" lines of code. However, there was no "extends JPanel". I added this myself, but after I added it, I did not get the "Design" or GUI building window, which lets one add components to the panel. I had to hand build the code.

The next custom panel I started as a "New | Java JPanel", which gave me

Code:

public class MySecondPanel extends javax.swing.JPanel {


With this panel, I did get the "Design" window so I can click and drag widgets to the panel. Still thinking that I needed the panel to be a "bean", I added "implement Serializable" and propertySupport code (for non-gui properties).

I read somewhere that Java components are already in fact "beans". Therefore I now know that I don't need the "implement Serializable". I'm not sure about the "propertySupport" stuff for my non-gui fields but I think I'm getting a better handle on what's going on.

I figure the panels that I started as "New | JavaBeans Compone" will have to be recreated starting with "New | Java JPanel" in order to get the "Design" window.

Thanks,
Bill
Back to top
Chuck Davis
Posted via mailing list.





PostPosted: Fri Mar 16, 2012 1:58 pm    Post subject: New JavaBeans Component vs. New JPanel Form and the "Design" pane Reply with quote

I agree with your conclusion. Sounds like you're on the right track.
Good luck and welcome to the world's finest IDE!

On Thu, Mar 15, 2012 at 8:55 AM, wahoodoss <address-removed> wrote:
Quote:
Hey Chuck, thanks for helping.

I think my confusion results because of a not complete understand of just what is a "Java Bean" and because I thought that in order to place a custom component, i.e. user created subclass of a standard component, on the palette it had to be a bean.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo