Community
Participate
Working Groups
The generated code can be placed incorrectly. Test case: Create a new visual class like JPanel. Drop a JCheckbox on the new panel. It will look like this: private JCheckBox getJCheckBox() { if (jCheckBox == null) { jCheckBox = new JCheckBox(); } return jCheckBox; } Switch to "source" mode and edit it to look like this: private JCheckBox getJCheckBox() { if (jCheckBox == null) { jCheckBox = new JCheckBox(); if (true) { jCheckBox.setSelected(true); } } return jCheckBox; } Now switch back to "design" mode, right-click on the checkbox and select "events->actionPerformed". Switch back to source mode and notice that the new code has been inserted inside the if-block previously added: private JCheckBox getJCheckBox() { if (jCheckBox == null) { jCheckBox = new JCheckBox(); if (true) { jCheckBox.setSelected(true); jCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed() } }); } } return jCheckBox; } Correct result: The inserted code should not be inside any conditional (or looping) blocks inside the getJCheckBox() method.