Specifying code generation preferences for the visual editor for Java

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

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, you can select the following preferences:
    • 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.

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