NBDemoNB6.0

NB 6.0 Demo (15 Minutes)

Description

This demo introduces many of the new features being introduced into NetBeans 6.0. Much of the content was adopted from Vincent Brabant's Flash demo.

Product Versions Supported

6.0 M7+

Points to Hit

NB 6.0 Rocks

Demo Prep

Install NB 6.0 M7 or greater

Gotchas

We're not even at Beta, anything can go wrong.

Demo

Project Groups

  1. Open 2 sample projects, GUI Form Examples and Anagram Game
  2. Choose File > Project Group > New Group. Name it General Samples and click Create Group.
  3. Set the group back to (none).
  4. Open 2 sample projects, JSTL Example and TomcatJSPExample
  5. Create a group named Web Samples.
  6. Toggle between the 2 groups.

Stop and Re-run on run

  1. Create a General Java Application named Looper.
  2. Add a method like the following and call it from the main method:
  3. Add something like the following:
      private static void loop() {
          int i = 0;
          while (true) {
              System.out.println(i++);
          }
      }
  1. F6
  2. Click the Stop icon in the Output window
  3. Click the Re-run icon

Run Profiles

  1. Change your loop code to the following (yes, this is hideously frail):
          loop(new Integer(args[0]));

          private static void loop(int j) {
              int i = 0;
              while (i < j) {
                  System.out.println(i++);
              }
          }
  1. Select Customize... from the combo box in the toolbar. which will open the project Run properties.
  2. Set the Arguments to 100.
  3. Click New and name the profile 200.
  4. Set the arguments to 200.
  5. Run both profiles.

Editor Features

Parameterized Constructors from Code Completion

  1. Add a couple of integers, for example:
      private int x;
      private int y;
  1. Press Ctrl+Space to open the code completion window and select the recommended constructor.
  2. As a bonus, use the tip to create the missing Javadoc for the constructor.

Code Generation (Alt+Insert)

  1. Use Alt+Insert (or Source > Generate Code) to quickly generate code, for example equals and hashCode.

Maximize Editor

  1. Shift+Escape (notice other windows are now pinned).

Instant Rename (Ctrl+R)

  1. With the editor maximized (so all code can be seen), select the x instance variable. Notice all occurrences are highlighted.
  2. Press Ctrl+R and change the variable names for x and y to foo and bar (note they must be declared private in order for instant rename to work).

Smarter Code Completion

  1. Put an empty line after the int i = 0; in the loop() method and then type on it ArrayLi and press Ctrl-Space.
  2. Press Enter and then type <String> and a space.
  3. Press Ctrl-Space and point out that the editor recommends intelligent variable names. Press Enter to take the first suggestion.
  4. Type a space and then = new and press Ctrl-Space again to point out that the top of the list contains the most likely candidate classes. Press Enter to take the first suggestion, then press Enter again to complete it and then type a ; and press Enter again to create a new line.
  5. Type al.ad and then press Ctrl-Space. Press Enter to take the first suggestion. Type "one" and then press Enter to finish it and move the cursor to the end of the line (this did not work this way in the past - 5.5 would insert a new line!), then type a ;
  6. Press Enter to create a new line and then type i = al. and press Ctrl-Space. Point out that the methods that return int are listed at the top (since the variable on the left of the equals sign is an int). We don't want those though, so type ge to narrow the list to the get() method. Press Enter. Type in a parameter of 0 and press Enter to finish that. Then type . and point out that when the code completion comes up, the methods in the String class that return ints are listed first.  :-)
  7. Type index to move down to the indexOf() entries and pick one of them and then type in a parameter.

Semantic Coloring

  1. Some of this can already by seen (instance variables are green, arguments orange)
  2. Mark the loop method with @Deprecated and notice it's marked with a strike-through.
  3. Add the following and notice the coloring:
          public static int staticClassMember;  
          private int unusedInstanceMember;

Method Exit Points

  1. Highlight the boolean return type of the equals method to see all the places it returns from.

Local History

  1. Save Main.java
  2. Delete the equals method and save it again.
  3. Right-click Main.java in the Projects tab and select Local History > Show Local History.
  4. Compare the differences.
  5. Right-click the previous entry and choose Revert from History to bring back the equals method.

Debugging

One of the new debugger features is "step over expression". You can add the following code to the looper method to demonstrate it:

ArrayList<String> al = new ArrayList<String>();
al.add("one");
i = al.get(0).indexOf("one");


Demo Cleanup

Delete the Looper project

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo