Book Image

NetBeans IDE 8 Cookbook

By : David Salter, Rhawi Dantas
Book Image

NetBeans IDE 8 Cookbook

By: David Salter, Rhawi Dantas

Overview of this book

<p>From the start to the end of a Java project's lifecycle, this book will show you how to perform many key tasks with the NetBeans IDE, uncovering more about mobile, desktop, and enterprise Java along the way.</p> <p>You will start by creating Java projects and learning how to refactor and use NetBeans tools to increase developer efficiency. You will then get a walkthrough of how to create a desktop application before covering JavaFX and mobile applications and how to use external services within them. Having seen how to create many different types of applications, you will then be shown how to test and profile them before storing them in revision control systems such as Git or Subversion. Finally, you will learn how to extend NetBeans itself by adding new features to the IDE.</p>
Table of Contents (19 chapters)
NetBeans IDE 8 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a property


In this recipe, we'll see how we can create properties directly within a class without having to first add fields to the class and then add accessors for the fields.

Getting ready

First we will need to create a new project, so please refer to the recipes in Chapter 1, Using NetBeans Projects, for creating Java projects. To help follow this recipe, when creating a project, enter CreatingProperties as the project name and ensure that a main class called com.davidsalter.cookbook.creatingproperties.CreatingProperties is created.

How to do it…

To show how to create properties within a class, let's first create a class to represent a customer and then add some properties to the Customer class:

  1. Right-click on the CreatingProperties project, and select New and Java Class….

  2. On the New Java Class dialog, type Customer as the Class Name field.

  3. On the Package selection, click on the dropdown and select com.davidsalter.cookbook.creatingproperties.

  4. Click on Finish.

  5. A blank Customer class will...