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.
If the Form Editor's Listener Generation Style has changed when a project is re-opened, the project may become un-compilable under certain circumstances. To reproduce the bug: 1) Create a new project; 2) Make sure the Form Editor setting for Listener Generation Style is "Main Class"; 3) Add a WindowClosing (for example) event handler if there isn't one already (I think the default puts a System.exit(0); event handler); 4) Compile and save; 5) Switch to the Default project; 6) Switch the Form Editor setting for Listener Generation Style to "Anonymous Innerclasses"; 7) Switch back to the new project; 8) Do something inoccuous, such as adding a Title to the JFrame --Note how the initComponents rewrites itself in the "Anonymous Innerclasses" style--; 9) Try to compile. You'll get a message along the lines of: << MyJFrame.java [39:1] MyJFrame is not abstract and does not override abstract method windowOpened(java.awt.event.WindowEvent) in java.awt.event.WindowListener public class MyJFrame extends javax.swing.JFrame ^ >> To fix the problem, one must switch the Form Editor Listener Generation Style setting to something else and back whilst the project is open. The problem, of course, is the utter puzzlement of the user when this occurs --he has no idea what went wrong and will, in all likelihood, lose a day trying to find out what is wrong with NetBeans. Like I did. ;-)
Reproducible in 20040314; j2sdk1.4.2_03
The "Main class" listener type generation requires a bit of careful usage from the developer - as it adds some code to unguarded area so it cannot remove it freely (i.e. it does not know if the listener implementation was added by the user or by itself). There is some warning I think in the help. I don't know how to fix this at this moment.
My impression (I may be wrong) is that the IDE should either: 1) When it loads a project, compare the Form Editor's current Listener Generation Style setting with the just-loaded project's. If different, immediately rebuild the code as if the setting had just been switched to its current value. or 2) When it loads a project, switch the Form Editor's Listener Generation Style setting to the project's value, and warn the user that this has happened (or maybe offer the user a choice between the two options, like when the IDE suggests how to "fix" incomplete interface implementations...).
But the generation style is currently stored only as a global setting, not per project or per form setting. But I think that is another problem. The basic problem here is when switching from "Main Class" style to another - how to distinguish whether to remove a listener implementation from the main class or not.
*** Issue 48328 has been marked as a duplicate of this issue. ***
Please see issue 48328 and comment.
I also think this could be considered P2 as it can cause corruption (or at least unwanted and difficult-to-revert diffs) in user code.
I also think it's P2 issue and potentinally should be mentioned in release notes.
Mentioning the potential problem in release notes makes sense - as this topic disappeared from help, but there is no need to give this P2 priority.
"there is no need to give this P2 priority." - three people already said that it is P2
Fixed - Listener Generation Style of the form is stored in the form file by now.
*** Issue 57015 has been marked as a duplicate of this issue. ***
verified