Tips and Tricks of NetBeans
October 9, 2010 3 Comments
Hello friends.. Wassup??
This blogpost is all about some important tips and tricks about using NetBeans.
Many people amongst us are using NetBeans for programming java, ruby, and many other languages. So in this blogpost I will cover some of the tips which I encountered while using NetBeans so that we can write our code effectively.
The very first thing I am going to tell here is very basic thing creating a application project in NetBeans IDE.
Follow these steps : File -> New -> Java (categories) -> Java Application
After making your selection click next and the window will be shown as
Now give some name to your project (Red Rectangle)and click Finish (shown by Red arrow). And then your project will look like
Now another feature is that NetBeans automatically completes code for you according to information you provide:
Now on the left hand side of line 17 you see a bulb after clicking on that bulb like image select the appropriate option I selected surround Block with try-catch and my code will look like:
This figure shows that the code highlighted is created by NetBeans.
And another type of code completion is that while selecting the function there is no need to type it all in the following figure I just typed the object name followed by a . (dot) and e which is the starting letter of my function this will pops up entire list of function related to that object and shows the functions of which name starts with the e
In our large program we need to move from one function to other or from one class to another class file then to search that class file in our program is again tedious job so there is another method to jump from one class to another and one method to another “CTRL + mouse click” to jump from one class to another just point to the class where you want to jump and press CTRL button the name is highlighted so now click on it it just work as a hyperlink to go from one class file to another. Just as shown in the highlighted area.
There are some situations when we need to change the name of some class and it is very tedious job to change that name in complete program so NetBeans provides the feature known as “Refactor”.
Suppose I want to change the name of fun.class in my program. We just have to do is that point cursor on it right click and select refactor
As you can see that after selecting refactor there are various other submenus such as Rename, Move, Copy, Pull Up, Push Down. Pull Up moves any function which we want to be in super class and written in sub class and in the same way push down moves the function to the sub class from super class.
So Rename changes the name of a file or function and make changes to whole program wherever that function occurs. After selecting that menu the dialog box will open in which I am going to change name of fun to funNew.
As shown in figure change the name and click on “Refactor” and the result is shown in following diagram with red rectangles.
NetBeans can be made to adopt the features which you want in other words we can say that it adopts the coding style of programmer there are some preferences which enables us to do that.
Go to Tools-> Option
And from the options present there you can change the way your IDE works.
So friends just toy with this NetBeans and find some more tips and tricks…