Skip to main content

Netbeans 6.0 - Code generation


The Java editor is capable of generating often used constructs for you automatically. Press Alt+Insert to invoke the code generation menu and pick what you want to generate

To add import statements: Use error hints: Click on the error mark with the light bulb or press Alt+Enter. It will offer you a list of possible classes to import. Pick the proper hint and you are done

Use the import class dialog: Put the caret into the name of an unimported class and press Alt+Shift+I. A list of possible classes to import will appear. Use the smart fix import: Press Ctrl+Shift+I. You will get a dialog that lists all unresolved identifiers in the source. If there is more than one option for resolving the identifier you may choose using the combo box. Classes shown in gray do not fit for some reason.

Method exit points: Putting the caret on the return type of a method definition will highlight all places where the method can exit

Exception throwing points: Putting the caret on an exception in a method declaration throws clause will highlight all the places where that exception can be thrown

If you want to surround a piece of text with a template, just select the text and invoke hints with Alt+Enter

Sometimes it is useful to select text based on Java syntax. To do this, press Alt+Shift+PERIOD (Ctrl-Shift-PERIOD on a Mac) to expand the selection and Alt+Shift+COMMA (Ctrl-Shift-COMMA on a Mac) to shrink the selection based on the structure of your Java source code

How to use Live Templates

Type a few letters from the name of the template e.g. fo| and invoke the code completion.
Pick the template you want to use. If there is a suitable collection it will be filled in for you. Several parts of the template will be rendered in blue. You may cycle between them using the Tab key. Editing the fields will change the part of the code accordingly. Press Enter or Esc to finish editing the template. Notice that if you move out of the blue boxes with the cursor the "edit template mode" continues (so you may get back using the Tab key) until you actually change text outside of the blue box.

Creating a new template You can define new templates: go to Menu->Tools->Options, then choose the Editor category and the Code Templates tab. You may want to look at the existing Java templates and try to create your own

Javadoc popup window Put the caret on a symbol of choice and press Ctrl+Shift+Space. Javadoc view window Go to Window->Javadoc View in the main menu. This will open a separate window which always shows Javadoc for the element under the caret

Opening a type in the editor If you know the name of the type (class, interface, annotation or enum) you want to open, press Alt+Shift+O and type the name into the dialog. Notice that you can use prefix, camel case and wild cards

Navigating to source or declaration Place the caret on a type or variable name and press Alt+O or Alt+G. The former will open the source declaration of the type in the editor; the latter will take you to the declaration (e.g. to the place where a variable is defined.) Hyperlinking A similar action can be achieved by holding down the Ctrl key and clicking on an element with the mouse.

Implements/Overrides annotation Methods which implement or override another method are marked with a glyph in the editor gutter. Clicking the icon will take you to the overridden method or to the method from the interface. Pressing Ctrl+B does the same.

Declaration Window If you want to see the declaration of a given element but you don't want to open it in the editor, you can open the Declaration View, which always shows the declaration of the element under the caret

Comments

Popular posts from this blog

Investing in Gold

Like many, I keep hearing about looming recession and Gold as a hedge. But how exactly gold is going to help me and if yes, how to invest is something running behind my mind.  So here is my work on it and hope it helps you too. Why Invest in Gold ?  Fiat currency we are holding is loosing its value at the rate of inflation. But before fiat currency, gold is the standard. Based on current technology, its difficult to extract gold. so in the demand vs supply equation, supply cant balloon like central banks printing money at their will. so i dont need to worry about Gold loosing its value over time. On Supply part, As per World Gold Council estimate 190,040 metric tones extracted and another 54000 metric can be extracted from ground. Refer :  https://www.gold.org/about-gold/gold-supply/gold-mining/how-much-gold On the Demand part, Below are the key drivers of Gold demand Source: Thomson Reuters GFMS, World Gold Council As an investment, From individu...

Upa Yoga

Pakistan

Watching recent tweets and news article in western media, I would like to spend some quality time and understand the enmity between India and Pakistan. In this pursuit, some interesting reads and my take a ways India-Pakistan partition - Birth of a country based on religion  Subsequent incidents Current states 9/11 Terrorist attacks and Intelligence war What wrong with Islam State of Pakistan and reasons for some of its troubles by a Pakistani 10-September - 2019 Pakistan Army begins operation in POK