NetBeans Tips and Tricks
Posted
by cdmckay
on Stack Overflow
See other posts from Stack Overflow
or by cdmckay
Published on 2009-03-10T03:16:53Z
Indexed on
2010/03/20
3:51 UTC
Read the original article
Hit count: 405
I just saw an Eclipse tips & tricks post and was wondering if anyone had any tips & tricks for my IDE of choice: NetBeans.
Here's a few I know and find to be useful:
Removing a package: After you remove a package in NetBeans, it sticks around as a grayed-out package in your Project view. To get rid of that, switch to Files view and delete the directory.
Alt-Insert (in Windows) opens up a Generate submenu at your cursor. A nice shortcut for quickly generating getters/setters (among other things).
Selecting a chunk of code, right-clicking and then clicking "Refactor > Introduce Method" will have NetBeans introduce a method, complete with arguments and return value. Of course you have to make sure the chunk of code only has one return value.
Sometimes when you run a build and it crashes, the Java window sticks around at the bottom. I used to just click X until Windows let me End Task, but there's a nicer way to get rid of them. Click "Run > Stop Build/Run" and NetBeans will close the window for you. It'll even let you close multiple applications at once.
These may seem obvious to grizzled NetBeans developers, but I thought they might be useful for NetBeans newbs like me. Anyone else have any tips/tricks to share?
Here are some from the comments:
NetBeans allows for code templates. You can even add yours on the Code Templates tab under the Editor settings on the Options window. Some examples:
Type
sout
and hit the tab key as a shorcut forSystem.out.println("")
Type
psvm
and hit the tab key as a shorcut forpublic static void main(String args[]) {}
Ctrl Shift C: Comments out the selected block of code.
Alt Shift F: Formats the selected block of code.
Ctrl E: Deletes current line.
Ctrl Shift I: Fixes your imports, handy if you've just written a piece of code that needs a lot of packages imported.
© Stack Overflow or respective owner