NetBeans enables the developer to easily move classes around different projects and packages. This is a good practice and, more often than not, is followed. When renaming a project, NetBeans gives the developer the possibility of renaming the folder where the project is contained to the same name of the project. This emphasizes to the developer that something deeper is happening. The Ctrl+R shortcut is not enough in itself so NetBeans shows the Rename Project dialog. Renaming a project works a bit differently from renaming a variable, since in this action NetBeans needs to rename the folder where the project is placed. Under Project Name enter FileSystem and tick Also Rename Project Folder after that, click on Rename.Navigate to the Project window, right-click on the project name, RenamingElements, and choose Rename….On the Rename Class dialog enter FileManipulator and press Enter.To rename a class navigate to the Projects window and press Ctrl+R on the RenameElements.java file.On the Rename Method dialog, under New Name enter recursiveFilePrinting and press Refactor.Place the cursor on the top of the method declaration, printFiles, right-click it then select Refactor and Rename….To rename methods, perform the steps below: Place the cursor on the top of the String parameter named string and press Ctrl+R.Our class contains several variables we can rename: Type util under New Name and click on Refactor. The next step is to rename the package, so place the cursor on top of the package name, renameelements, and press Ctrl+R.Ī Rename dialog pops-up with the package name. PrintFiles(string + parator + directory) With the project created we will need to clear the RenameElements.java class of the main method and insert the following code: package renameelements Under Name and Location: name the project as RenameElements and click Finish.On New Project window, choose Java on the Categories side, and on the Projects side select Java Application.Create a new project, this can be achieved by either clicking File and then New Project or pressing Ctrl+Shift+N.This recipe focuses on how the IDE handles the renaming of all elements of a project, being the project itself, classes, methods, variables, and packages.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |