Personal notes on Java
For other technologies like HTML, CSS, .NET, PHP, etc. check my other blog

IDE



Netbeans

Overview NetBeans is a free, open-source Integrated Development Environment (IDE) for software developers. You get all the tools you need to create professional desktop, enterprise, web, and mobile applications with the Java platform, as well as:
  • C/C++: Develop professional native applications in C, C++, and Fortran for a variety of platforms including Windows, Linux, Mac OS, and the Solaris operating system;
  • PHP: NetBeans PHP IDE provides a fast integrated development environment for creating, running, and debugging PHP applications in one small download;
  • JavaScript: The NetBeans IDE offers full editor support for JavaScript and CSS, including a JavaScript Debugger and a JavaScript Library Manager;
  • Groovy: NetBeans IDE directly supports Groovy, a dynamic scripting language for the Java Platform, and Grails, a web application framework that leverages the Groovy language. Use it to develop 100% pure Groovy applications, or mix Groovy with Java and take advantage of Groovy's dynamic nature in your Java projects.;
  • Ruby and Ruby on Rails: NetBeans IDE offers a powerful Ruby editor including code completion, a debugger, and full support for Ruby on Rails. You can use your local ruby binaries or rely on the included JRuby runtime;
The complete features list can be checked here.

UML plugin for NetBeans

NetBeans has a UML plugin available for free."Call it Reverse Engineering. Netbeans 5.5 Unified Modelling Language (UML) tools enables you to generate UML Diagrams - class diagrams, sequence diagrams, activity diagrams, etc. al automatically from your source code. There is no need to manually draw the UML diagrams any more for your Java source code".

Install this plugin using the Netbeans update center. Go to Tools -> Update Center. After all the module lists have been retrieved select the UML Modelling Pack.

Tutorial on how to use this plugin.

More information about UML on NetBeans here.

Netbeans Tips and Tricks

  • Generate Javadoc: see the Javadoc page.
  • Refactoring with NetBeans: see the refactor page.
  • Split screen editing on a single file
    1. Right Click on the file title of the editor pane and select the “Clone Document” option.  Selecting this will cause two separate windows to be opened – both editing the same file.
    2. Grab the file title in the second editor pane and drag and drop it onto the first editor pane.  When you drop the editor pane, you’ll have split screen editing of your file.
  • Code Folding
    Select the code you want to put inside the Fold. Click on the yellow lamp to insert the fold.
    (more info here)
    Example:
  • Diff tool
    Open the 1st file in the IDE (this file wont be editable in the diff tool);
    Go to Tools -> Diff;
    Choose the second file (this file will be editable);
  • NetBeans Code Templates
    • view and edit/add existing code templates: Choose Tools > Options (NetBeans > Preferences on Mac) to open the Options window. Select Editor > Code Templates.
    • trycatch template: by typing in 'trycatch' then pressing Tab. The template is added to your file.
  • View a list of keyboard shortcuts: open the IDE's Keyboard Shortcuts Card by choosing Help > Keyboard Shortcuts Card from the main menu. Alternatively you can check/change keyboard mappings by accessing: Tools -> Options -> Keymap.
    • Code completion: When you type in tags and attributes, suggestions for code completion automatically appear in a pop-up box. Pressing Enter completes the suggested tag.
    • Format your code: Right-click in the editor and choose Format (or alt+shift+f).
    • Find occurrences: Highlight a block of text, and press Ctrl-F (⌘-F on Mac). All matches become highlighted in the editor. To toggle highlighting, press the Toggle Highlight Search ( ) button (Ctrl-Shift-H) in the editor's toolbar.
    • Create a bookmark: Press the Toggle Bookmark ( ) button (Ctrl-Shift-M) to create a bookmark in the editor's left margin. Wherever you are in the file, you can then jump to the bookmark by pressing the Previous/Next Bookmark buttons in the editors's toolbar.
    • Copy a code snippet up or down: Highlight a code snippet, then press Ctrl-Shift-Up/Down.
    • Highlight opening and closing tags: Place your cursor on either the opening or closing tag, and both are highlighted in yellow.
    • Applying TODO notes in your code is a useful way to keep track of tasks that you need to complete. You can use the IDE's Tasks window (Ctrl-6) to view all TODO notes, as well as any syntax or compile errors contained in your project.
      NOTE: You can control the keywords that display in the Tasks window. Open the Options window (Tools > Options; NetBeans > Preferences on Mac), then choose Miscellaneous > Tasks.
    • Comment/Uncomment source code: highlight the code and press CTRL-SHIFT-C

Change Netbeans Editor Theme

You can define it manually or import an existing theme.
Go to: Tools -> Options -> Editor -> Import

You can find many themes on the web:
One of my favorites is zen-burn but keep reading:
The original theme has a great flaw: the "Mark Occurrences" background turns the text unreadable! I like to change it to a dark red color rgb=[153, 0 , 0].
So after importing the theme into Netbeans update it with:
Tools -> Options -> Font & Colors -> Syntax -> Select "Java" for the language -> Select " Mark Ocurrences" -> change the background color to [153, 0 , 0].


Connecting to a MySQL database from Netbeans

See the MySQL section.

Add a third-party bean to Netbeans pallete

  1. Tools > Palette > Swing/AWT Components
  2. Click on the Add from JAR... button. NetBeans asks you to locate the JAR file that contains the beans you wish to add to the palette. Locate the file you just downloaded and click Next.
  3. NetBeans shows a list of the classes in the JAR file. Choose the ones you wish you add to the palette

Sem comentários:

Enviar um comentário