Professional Documents
Culture Documents
CONTENTS INCLUDE:
n
About NetBeans IDE
Java Editor Overview
Updated
n
NetBeans IDE Java
for
Quick Start Tutorial NetBeans 6.5
n
Keyboard Shortcuts and
Code Templates By Geertjan Wielenga and Patrick Keegan
n
Hot Tips and more...
The NetBeans IDE has seen adoption snowballing over the past carefully thought out categories and it provides a thorough
years, particularly with the introduction of a completely new, exposition of optimal handling of Java code in the editor,
rewritten, slick Java editor. You’ll find this reference card helpful covering viewing, navigation, source handling, and refactoring.
if you want to get as much out of the Java editor as its authors Get NetBeans IDE: http://www.netbeans.org/downloads
intended when creating it. It lists all the keyboard shortcuts in
Right-click inside
Error underlinings in the editor to produce
red, by default. a list of menu items, for
refactoring and more.
The following features are new in NetBeans IDE 6.5 and can be of
particular use to you in the context of the Java editor.
NetBeans IDE 6.5 is the
latest release of Sun’s award-winning
Enhanced Right-click a project, choose Properties, and you can configure applets to open-source IDE that enables developers to
Java Web Start be deployed via Java Web Start on JDK 6 Update 10 and above.
Support rapidly create Web, enterprise, desktop, and
Javadoc
Analyzer
Changes in your code mean changes in your Javadoc. Choose
Tools | Analyze Javadoc and the Javadoc will be updated according
mobile applications with Java, C/C++,
to your code changes. JavaScript, Ruby, Groovy and PHP.
Groovy Mix and match Groovy and Java for the first time in NetBeans IDE 6.5.
Support
Quick Search Know about an action but not how to invoke it? Click Ctrl-I and the
cursor lands in the text field in the top right of the editor, where you can
type a keyword (such as ‘format’) and then related items appear.
Eclipse Project Enhanced feature in 6.5, letting you resynchronize your work in the
Import and IDE to its original Eclipse project. Ideal for teams using multiple IDEs
Synchronization simultaneously.
2. In the New Project wizard, expand the Java category and Alt-Left/Alt-Right/Ctrl-Q Go backward/forward/to last edit
select Java Application. Then click Next.
3. In the Name and Location page of the wizard, type Compiling, Testing, and Running
"HelloWorldApp" in Project Name and type F9 Compile package/ file
"helloworldapp.HelloWorldApp" in the Create Main Class
F11 Build main project
field. Then Click finish.
4. Because you have left the Create Main Class checkbox Shift-F11 Clean & build main project
selected in the New Project wizard, the IDE has created a Ctrl-Q Set request parameters
skeleton class for you. You can add the "HelloWorld!"
Ctrl-Shift-U Create JUnit test
message to the skeleton code by replacing the line:
Ctrl-F6/Alt-F6 Run JUnit test on file/project
// TODO code application logic here
with the line: F6/Shift-F6 Run main project/file
System.out.println("Hello World!");
Debugging
5. From the IDE’s menu bar, choose Run > Run Main
Project (F6). The Output window should show you the Ctrl-F5 Start debugging main project
"HelloWorld!" message. Ctrl-Shift-F5 Start debugging current file
Opening and Toggling Between Views Alt-Shift-I Fix selected class’s import
Keyboard Shortcuts & Code Templates, continued Java Editor Code Templates, continued
St String
Refactoring
ab abstract
This table provides short descriptions of the refactoring
bo boolean
operations that are available in the IDE, mostly from under
br break
the Refactoring menu and within the Java editor itself,
ca catch (
when you right-click within it.
cl class
Refactoring Operation Description cn continue
The following are some of the many cool NetBeans IDE 6.0
keyboard shortcuts that no programmer will be able to do 5. Add/Remove comment lines. Select one or more lines, press Ctrl-/ and then the se
without, once you know they’re there. Not all of these are new commented out, as shown below. Press the same keys again and the commented lines
be commented. This was, of course, also possible in previous releases, but previously
in 6.0, some were there before, but deserve to be highlighted different keyboard shortcuts, one for commenting and one for uncommenting. Now th
because often they’re overlooked. been combined into one shortcut, you can quickly toggle between comment and uncom
makes
5. this activity
Add/Remove muchlines.
comment fasterSelect
and more
one orefficient.
more lines, press Ctrl-/ and then the selected lines
commented out, as shown below. Press the same keys again and the commented lines will no lon
DZone, Inc. | be commented. This was, of course, also possible in previous releases, but previously there were
www.dzone.com
different keyboard shortcuts, one for commenting and one for uncommenting. Now that they hav
5
NetBeans IDE Java Editor
tech facts at your fingertips
4. Inplace rename. If you want to change a variable, method, or other item, of which more than one
are used in your code, press Ctrl-R, and you will see that all instances of the item turn blue at the
same time, as shown below. Now, when you change the selected item, all the other instances change
10 atHandy
the sameEditor Shortcuts,
time, until continued
you press Escape, at which point the inplace rename mode
8. Jumpcomes
toto an edit.
last end. Often, you find yourself in a situation
where you have edited in one document, while you
5. Add/Remove comment lines. Select one or more lines, currently find yourself in a completely different document.
press Ctrl-/ and then the selected lines are commented How do you get back to the place where you were last
out, as shown below. Press the same keys again and the editing your code? That is likely to be the place where you
8. Jump
want to back
to get last edit.
to, inOften,
order you
to dofind
someyourself
morein a situation
editing. where you hav
commented lines will no longer be commented. This while you currently find yourself in a completely different document. How
was, of course, also possible in previous releases, but Now,
placewhenever
where youyou click
were Ctrl-Q,
last editing the lastcode?
your editedThat
document
is likely to be the place
previously there were two different keyboard shortcuts, is
to, in order to do some more editing. Now, wheneverlast
found, and the cursor lands on the line where the you click Ctrl-Q, the
edit took
found, andplace.
the Alternatively,
cursor lands on you
the can
line click
where the
the button
last took place. Altern
edit
one for commenting
5. Add/Remove commentandlines.
one for uncommenting.
Select Now
one or more lines, Ctrl-/ and then the selected lines are
press
commented out, as shown below. Press the same keys again and the commented button
shown shown
below,
lines will below,
in the top
no longer in the
left top left of
corner corner of the Source
the Source Editor:Editor:
that they have been
be commented. combined
This was, into
of course, one
also shortcut,
possible you canreleases,
in previous but previously there were two
quickly toggle between comment and uncomment, which
different keyboard shortcuts, one for commenting and one for uncommenting. Now that they have
been combined
makes into one
this activity muchshortcut,
fasteryou
andcan
morequickly toggle between comment and uncomment, which
efficient.
makes this activity much faster and more efficient.
9. Bookmarks.
9. Bookmarks. When you you
When presspress
Ctrl-Shift-M, the current
Ctrl-Shift-M, line line is "bookma
the current
6. Inspect members/hierarchy. Both the members of the current class as well isthatitsyou can later
as“bookmarked”.
hierarchy can quickly
What
be cycle
this meansback/forward
is that youtocan
it (with
later Ctrl-Shift-Period a
6. Inspect
displayedmembers/hierarchy.
and then filtered. PressBoth the members
Alt-F12 of the of the current file
and the ancestors arebookmarked
shown.
quickly line gets a small
Onback/forward
cycle the to iticon
(withinCtrl-Shift-Period
the left sidebar,andas shown
below, unti
other hand,
current if you
class pressasCtrl-F12,
as well the current
its hierarchy can befile's membersand
displayed on thehere:
are displayed, as shown line again, to remove the bookmark:
Ctrl-Shift-Comma). The bookmarked line gets a small
then filtered. Press Alt-F12 and the ancestors of the current 10 Handy Editor iconShortcuts
in the left sidebar, IDE
in NetBeans as shown
6.0 below, until you press
file are shown. On the other hand, if you press Ctrl-F12, Ctrl-Shift-M on the line again, to remove the bookmark:
10 Handy Editor Shortcuts in NetBeans IDE 6.0 http://netbeans.dzone.com/print/280
the current file’s members are displayed, as shown here:
10 Handy Editor Shortcuts in NetBeans IDE 6.0 http://netbeans.dz
3 of 4
2 of 4 10. Highlight
10. Highlight exit exit points.
4/21/08
points. 10:44Place
PlaceAM the the cursor
cursor on the
on the return type and yousee
will i
10. Highlight
points exit points.
highlighted: Place the cursor on the return typereturn
and youtype
will immediately all ex
and you
points will immediately see all exit points highlighted:
highlighted:
7. Switch between documents. When you have multiple documents open at the same time, press
7. Ctrl
Switch
and between documents.
Tab, and then When
a small popup you have
appears. Youmultiple through the popup, which displays all
can scroll
the
documents open atand
open documents, thethen
same time,the
choose press Ctrl and
document thatTab,
you want to open:
and then a small popup appears. You can scroll through
the popup,
7. Switch which documents.
between displays all When
the open documents,
you have multiple and
documents open at the same time, press
Ctrl and Tab, and then a small popup appears. You can scroll through the popup, which displays all
then choose the document that you want to open:
the open documents, and then choose the document that you want to open:
Source URL: http://netbeans.dzone.com/news/10-handy-editor-shortcuts-netbeans-ide-60
Quick Options Window Overview
to, in order to do some more editing. Now, whenever you click Ctrl-Q, the last edited document proxy settings.
is Proxy Settings
n
found,
8. Jump andtothe
lastcursor lands on
edit. Often, thefind
you lineyourself
where the
in alast edit took
situation place.
where youAlternatively,
edited inyou
have Editor onecan click the
document,
button shown below,find
in the top left Sets the editor-specific options, Code Folding
in corner of the different
Source Editor: n
while you currently yourself a completely document. How do you get backspecifically
to the those relating to code
Code Completion
n
place where you were last editing your code? That is likely to be the place where you want to get back
folding, code completion, camel case
to, in order toSource
do some URL:
more editing. Now, whenever you click Ctrl-Q, the last edited document is indentation, code templates,
behavior,
Camel Case Behavior
n
FYIand thehttp://netbeans.dzone.com/news/10-handy-
found, cursor lands on the line where the last edit took place. Alternatively, you canand
button shown below, in the top left corner of the Source Editor:
click the
macros. Indentation
n
Code Templates
editor-shortcuts-netbeans-ide-60
n
Macros
n
n Profiler
n ToDo Tasks
Thanks to the following people who kindly gave of their
n JavaScript
time and expertise in reviewing this refcard: Adam Bien,
n Versioning
Geertjan Wielenga is the NetBeans technical Rich Client Program- Pro NetBeans IDE 6 Rich
writer responsible for documentation related ming will help you get Client Platform Edition
to the NetBeans Java editor. He is co-author of started with NetBeans focuses on the new
the book Rich Client Programming: Plugging module development, features of NetBeans
into the NetBeans Platform. He is known for his master NetBeans’ 6 as well as what has
popular blog at http://blogs.sun.com/geertjan, key APIs, and learn changed since NetBeans
as well as for his role as a Zone Leader at Javalobby. proven techniques 5.5, empowering you to
for building reliable be a more effective and
Patrick Keegan has been writing about the desktop software. productive developer.
NetBeans IDE for over 9 years. In addition
to writing help and tutorials, he is co-author
of the NetBeans IDE Field Guide and has BUY NOW
contributed to other books on NetBeans books.dzone.com/books/richclientprog
and Java. books.dzone.com/books/pronetbeans
DZone, Inc.
1251 NW Maynard
ISBN-13: 978-1-934238-13-4
Cary, NC 27513
ISBN-10: 1-934238-13-9
50795
888.678.0399
DZone communities deliver over 4 million pages each month to 919.678.0300
more than 1.7 million software developers, architects and decision
Refcardz Feedback Welcome
makers. DZone offers something for everyone, including news, refcardz@dzone.com
$7.95
tutorials, cheatsheets, blogs, feature articles, source code and more. Sponsorship Opportunities 9 781934 238134
“DZone is a developer’s dream,” says PC Magazine. sales@dzone.com
Copyright © 2008 DZone, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, Version 1.1
photocopying, or otherwise, without prior written permission of the publisher.