Specifying visual editor preferences for code generation

There are several code generation preferences that you can set for the visual editor.

To specify code generation preferences:

  1. From the main menu, click Window > Preferences > Java > Visual Editor to open the visual editor preferences.
  2. On the Code Generation page, select either of the following options:
    • Generate try{}catch() block
    • Generate a comment for new expressions
    The following code shows a JPanel initialized with the try{}catch() block:
    private JPanel getJPanel1() {
    		if (jPanel1 == null) {
    			try {
    				jPanel1 = new JPanel();
    			}
    			catch (java.lang.Throwable e) {
    				// TODO: Something
    			}
    		}
    		return jPanel1;
    	}
    The following code shows a JPanel without the try{}catch() block of code:
    private JPanel getJPanel() {
    		if (jPanel == null) {
    			jPanel = new JPanel();
    		}
    		return jPanel;
    	}
    The following line of code is an example of what the generated comment looks like:
    this.add(getJPanel(), null);  // Generated
  3. Click OK to save your changes and close the Preferences window.

Parent topic: Setting visual editor preferences

Related tasks
Customizing the appearance of the visual editor
Making the visual editor the default Java editor

(C) Copyright IBM Corporation 1999, 2004. All Rights Reserved.