DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. How to Create & Import a JavaBean Component in NetBeans IDE (Part 2)

How to Create & Import a JavaBean Component in NetBeans IDE (Part 2)

Mark Stephens user avatar by
Mark Stephens
·
Nov. 05, 08 · Interview
Like (0)
Save
Tweet
Share
21.36K Views

Join the DZone community and get the full member experience.

Join For Free

In the final installment of this two part tutorial (part 1 here), we look at how to import and use your new JavaBean component in the NetBeans GUI Builder Matisse.

Adding a New JFrame

Once you have created your JavaBean, you are ready to import it into NetBeans. To be able to use it once it is imported however, we first need to create a new JFrame to house the Component in.

For the benefit of this example, in my case I have a project called PDFHelpBean. As shown in the screen shot below, to add a new JFrame to the project, right click on the "Source Packages" and from the resulting pop-up menu select "New" -> "JFrame Form".

New JFrame

NetBeans will now ask you to choose a name for this new Form. In this example it will be called "PDFHelpFrame". Once you have entered the name click "Finish" and NetBeans will generate a new JFrame class.

New JFrame

Importing the JavaBean component

Once you have added a new JFrame, you are ready to add the JavaBean component to the Matisse palette. From the "Tools" menu select "Palette" -> "Swing/AWT Components".

New JFrame

This will bring up a dialog box asking you from where you wish to import your JavaBean. In this case select the "Add from JAR" button.

New JFrame

Next, in the resulting file chooser dialog, navigate to the location where the JAR file containing your JavaBean is stored, and click "Next".

New JFrame

From the list of available components choose your Component and click "Next".

New JFrame

When choosing which category to add the Component to you are free to choose any you like. For the sake of this tutorial however, "Swing Controls" is selected. When you have chosen your category, click "Finish".

New JFrame

When the Palette Manager reappears click "Close".

Adding the JavaBean to Your JFrame

Once you've imported your JavaBean, you should see your component in the Palette. In my case I can see that the PdfHelpPanel component has been added.

New JFrame

You are now ready to add the component to your form. This is done by dragging the JavaBean from the Palette onto your JFrame. As you will see from the screen shot below, once the component has been added to the JFrame, the JavaBean properties will be exposed and available for the end-user to set. In my case (as indicated by the blue arrow) only the fileLocations property is visible

New JFrame

Once the end-user has set any properties they want to, they can run the application. This is done by clicking the green "Run Main Project" button - as indicated by the blue arrow in the screen shot below - in the NetBeans toolbar.

New JFrame

Upon running the application you will see your JavaBean running inside a fully functioning application. In my case PDF Help is shown in the screen shot below.

New JFrame

And thats all there is to it.  We hope you have found the tutorial useful.  You can see our finished PDFHelp JavaBean application at http://www.idrsolutions.com/help.php.

NetBeans Integrated development environment

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • 5 Steps for Getting Started in Deep Learning
  • Introduction to Container Orchestration
  • Low-Code Development: The Future of Software Development
  • How To Set Up and Run Cypress Test Cases in CI/CD TeamCity

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: