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.

Bug 41009 - Listener Generation Style problem
Summary: Listener Generation Style problem
Status: VERIFIED FIXED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 3.x
Hardware: All All
: P3 blocker with 2 votes (vote)
Assignee: Jan Stola
URL:
Keywords: RELNOTE
: 48328 57015 (view as bug list)
Depends on:
Blocks: 49085
  Show dependency tree
 
Reported: 2004-03-15 14:15 UTC by urhixidur
Modified: 2005-07-11 14:11 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description urhixidur 2004-03-15 14:15:25 UTC
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.   ;-)
Comment 1 Jaromir Uhrik 2004-03-15 16:18:32 UTC
Reproducible in 20040314; j2sdk1.4.2_03
Comment 2 Tomas Pavek 2004-03-15 17:50:25 UTC
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.
Comment 3 urhixidur 2004-03-16 12:52:25 UTC
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...).
Comment 4 Tomas Pavek 2004-03-16 14:38:12 UTC
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.
Comment 5 Jan Stola 2004-09-02 09:02:09 UTC
*** Issue 48328 has been marked as a duplicate of this issue. ***
Comment 6 David Konecny 2004-09-02 09:15:29 UTC
Please see issue 48328 and comment. 
Comment 7 Jesse Glick 2004-09-02 16:09:26 UTC
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.
Comment 8 Milan Kubec 2004-09-21 10:32:55 UTC
I also think it's P2 issue and potentinally should be mentioned in
release notes.
Comment 9 Tomas Pavek 2004-09-21 11:19:03 UTC
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.
Comment 10 David Konecny 2004-09-21 12:18:12 UTC
"there is no need to give this P2 priority." - three people already
said that it is P2
Comment 11 Jan Stola 2005-01-06 09:14:53 UTC
Fixed - Listener Generation Style of the form is stored
in the form file by now.
Comment 12 Jan Stola 2005-03-29 09:29:19 UTC
*** Issue 57015 has been marked as a duplicate of this issue. ***
Comment 13 Marek Grummich 2005-07-11 14:11:55 UTC
verified