This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
NB 5.0 dev build 20050927 JDK 1.5.0_05 A certain combination of options can produce uncompilable code. When components are generated as local variables they are not visible when Listener Generation Style is set to Main Class or One Inner Class.
There is no easy way to check for a conflict every time the user is changing some of the mentioned properties. To disallow such settings would be laborious and risky and i am not sure if it's worth the effort. in this context i changed the code generator so on each place in the code where a local variable from initComponents() is used in a listener method outside the initComponents() scope will be a comment with a warning and a explanation which settings could be the cause for the compile error. Checking in Bundle.properties; /cvs/form/src/org/netbeans/modules/form/Bundle.properties,v <-- Bundle.properties new revision: 1.179; previous revision: 1.178 done Checking in JavaCodeGenerator.java; /cvs/form/src/org/netbeans/modules/form/JavaCodeGenerator.java,v <-- JavaCodeGenerator.java new revision: 1.165; previous revision: 1.164 done
It looks like this fix has broken code generation of event listeners. Now it can generates syntaxtic wrong code: private class FormListener implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent evt) { if (evt.getSource() == // WARNING: Variable jButton1 should not be declared as local in initComponents() as long as // Forms property 'Listener Generation Style' is set to 'Main Class' or 'One Inner Class'. // Check the values set in components 'Use Local Variable' and // Forms 'Local Variables' and 'Listener Generation Style' properties. if (evt.getSource() == jButton1) { NewJFrame3.this.jButton1ActionPerformed(evt); } } }// </editor-fold> It produces wrong code in all cases when Listener Generation Syle is not set do Annonymous Inner Class
oops! should be ok now... Checking in JavaCodeGenerator.java; /cvs/form/src/org/netbeans/modules/form/JavaCodeGenerator.java,v <-- JavaCodeGenerator.java new revision: 1.166; previous revision: 1.165 done
verified