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 34835 - InplaceEditor.add*Listener could throw TooManyListeners exception
Summary: InplaceEditor.add*Listener could throw TooManyListeners exception
Status: VERIFIED WONTFIX
Alias: None
Product: platform
Classification: Unclassified
Component: Explorer (show other bugs)
Version: 3.x
Hardware: PC Linux
: P2 blocker (vote)
Assignee: _ tboudreau
URL:
Keywords:
Depends on:
Blocks: 29447
  Show dependency tree
 
Reported: 2003-07-09 16:23 UTC by Jaroslav Tulach
Modified: 2008-12-22 22:41 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jaroslav Tulach 2003-07-09 16:23:49 UTC
Is it possible that more than one listener will be
attached to a InplaceEditor? I guess it is not, as
it is guaranteed that only one InplaceEditor is
open at a time. If this is true, I suggest to
change the signature of addActionListener to throw
TooManyListeners exception. Then instead of
writing a complicated support for adding listeners
the implementors could choose to have just one field:

private ActionListener l;
public void addActionListener (l) {
  if (this.l != null) throw new TooManyListenersEx();
  this.l = l;
}

which is simpler and easier.
Comment 1 _ tboudreau 2003-07-14 08:39:29 UTC
No it can't, that's a checked exception.
Comment 2 Jaroslav Tulach 2003-07-14 09:18:43 UTC
Yes, it is checked exception, but I am not sure why that would clasify
this issue as invalid.

So once more. Please consider simplifying the life of InplaceEditor
writers by declaring

void InplaceEditor.addActionListener (ActionListener l) throws
TooManyListenersException

which properly expresses your desire to attach just one listener to
each InplaceEditor and simplifies the life of writers in both cases:

1. if they inherit after JPanel (that does not have addActionListener
method), they can simply write the code as described above with one
field variable.

2. if they inherit from JTextField (has the addActionListener method
and does not throw the exception) they do not need to do anything and
it will still continue to work.



Comment 3 _ tboudreau 2003-07-15 17:08:28 UTC
Closing - not a terribly compelling argument, IMO.  Compound
components here are really the exception, not the rule, so 90%
of the time it's fine.

Also, there is no guarantee that a component, or worse (and more
likely) a look and feel will not try to add its own action listener
to the component, causing the exception to be thrown - people may
see the throws argument and think they need to police it.

There are equally effective ways to police listeners, such as
clearing the listener list when clear() is called on the 
InplaceEditor.

Simpler and safer to leave it as is.
Comment 4 Marian Mirilovic 2003-07-28 17:00:11 UTC
verifying.