TaT InsertConstructorsNB65

Revision as of 16:43, 5 November 2009 by Admin (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)

Quickly insert constructors from super class in NetBeans

Contributed by: Hubert A Klein Ikkink


Reposted from this blog entry: http://mrhaki.blogspot.com/2009/05/quickly-insert-constructors-from.html

Tips and Tricks

To quickly insert constructors from a super class in NetBeans we only have to place the cursor in our class and go to Source | Insert Code... (or press Alt+Insert in Windows). For example we create a new Exception class for our application extending the java.lang.Exception class:

package com.mrhaki.netbeans;

public class AppException extends Exception {
    
}

NetBeans shows a pop-up window and we select Constructor....

File:insertcode1_TaT_InsertConstructorsNB65.png

We get a dialog window with all constructors from the java.lang.Exception class. We select the constructors we want and click on the Generate button.

File:insertcode2_TaT_InsertConstructorsNB65.png

Now our source code looks like this:

package com.mrhaki.netbeans;

public class AppException extends Exception {

    public AppException(Throwable cause) {
        super(cause);
    }

    public AppException(String message, Throwable cause) {
        super(message, cause);
    }

    public AppException(String message) {
        super(message);
    }

    public AppException() {
    }
    
}
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