Board index » jbuilder » TableCellEditor EventListenerList mechanism does not work with JBuilder9

TableCellEditor EventListenerList mechanism does not work with JBuilder9


2003-11-01 12:37:44 AM
jbuilder6
Hi everybody,
I have an application which has a view on different Oracle database queries
using a JDBTable. It also implements user defined Components and
implementing the TableCellEditor interface to do custom cell value
conversion in different customized JComponents derived from JComboBox,
JTextField and others.
Now I encountered a strange behaviour: the mechanism of adding and removing
events to / from an EventListenerList fails after selecting two cells. If
the first selected cell lost it's focus removeCellEditorListener() in my
class is called, but then, after selecting the second cell and then trying
to select another, third cell, removeCellListener() is not called again, so
that the second ItemChanged event is processed until the VM raises a stack
overflow exception. I reviewed several examples and could not find a
difference to my code.
The same application runs fine with the JBuilder7 DBSwing.jar, so there
seems to be a bug in the JBuilder9 DBSwing.jar. Does anybody encountered the
same problem and / or does anybody have a solution? The code is kinda
complex so I won't post it here (it's simply too much and nobody would read
it I guess).
Thanks in advance for any help.
Alexander Pohl
 
 

Re:TableCellEditor EventListenerList mechanism does not work with JBuilder9

In <3fa28d50$ XXXX@XXXXX.COM >Alexander Pohl wrote:
Quote
Now I encountered a strange behaviour: the mechanism of adding and
removing events to / from an EventListenerList fails after selecting
two cells. If the first selected cell lost it's focus
removeCellEditorListener() in my class is called, but then, after
selecting the second cell and then trying to select another, third
cell, removeCellListener() is not called again, so that the second
ItemChanged event is processed until the VM raises a stack overflow
exception.
It seems odd to me that you seem to be adding and
removing listeners so frequently, that is, in response
to cell selection events. Doesn't it make more sense
to just add the listeners once to the respective
column editors during initialization, and just leave
them in place? What in your design requires you to
be doing so much adding and removing of listeners?
Quote
I reviewed several examples and could not find a
difference to my code.
Does the example code also add and remove listeners so
frequently and under the same circumstances? Which
examples are you referring to? I just did a search
of the entire "samples" folder for "editlist" and
found nothing for "removeEditListener".
In fact, in most cases, the "addEditListener()" method
is called in the "jbInit()" method, and in the
remaining cases, the method is in initializing code:
there's really no indication given in any of these
examples that one should be swapping in and out
edit listeners in the manner you describe above.
Quote
The code is kinda complex so I won't post it here
(it's simply too much and nobody would read it I guess).
Is it unnecessarily complex?
Paul Furbacher [TeamB]
Save time, search the archives:
info.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
www.visi.com/~gyles19/fom-serve/cache/1.html
Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
 

Re:TableCellEditor EventListenerList mechanism does not work with JBuilder9

Hi Paul,
thanks for your reply.
Quote
It seems odd to me that you seem to be adding and
removing listeners so frequently, that is, in response
to cell selection events. Doesn't it make more sense
to just add the listeners once to the respective
column editors during initialization, and just leave
them in place? What in your design requires you to
be doing so much adding and removing of listeners?
Basically I am working on a project I did not developed initially myself,
but I am just busy modifiying and enhancing it to match some new
requirements of my customer. Why the code is at is is I don't know and I
don't have time to find out. I know for sure it worked fine until I switched
to JBuilder9.
Quote
Is it unnecessarily complex?
The described code is nothing more than a copy of the TableCellEditor sample
code from the Borland Help, but embedded into the projects code, of course,
which makes it unpostable here.
Quote
Does the example code also add and remove listeners so
frequently and under the same circumstances? Which
examples are you referring to? I just did a search
of the entire "samples" folder for "editlist" and
found nothing for "removeEditListener".
Yes, it does. Any example I found was just working this way and everybody
seems to have copied the Borland example code, which causes this behaviour.
The problem is solved by a workaround since I am using the appropriate
Borland libraries from JBuilder7. Since then the code works again and I
don't get any exceptions. So, at the end I still think there's a bug in the
new libraries of JBuilder9 at this point, or there has been a bug in the old
libraries and it is fixed now so the old example code crashes now.
By the way: I encountered a new problem with JDBTable. I need to find out on
which row in a dataset JDBTable is working when it calls my custom controls
setValue method, because I have to dynamically have to wrap a column's value
to another value to display. If you have time and a solution please review
my posting here in the newsgroup ('how to find out on which row JDBTable is
working when calling a custom combobox component's setValue() method').
Best regards,
Alexander Pohl
"Paul Furbacher [TeamB]" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote
In <3fa28d50$ XXXX@XXXXX.COM >Alexander Pohl wrote:

>Now I encountered a strange behaviour: the mechanism of adding and
>removing events to / from an EventListenerList fails after selecting
>two cells. If the first selected cell lost it's focus
>removeCellEditorListener() in my class is called, but then, after
>selecting the second cell and then trying to select another, third
>cell, removeCellListener() is not called again, so that the second
>ItemChanged event is processed until the VM raises a stack overflow
>exception.

It seems odd to me that you seem to be adding and
removing listeners so frequently, that is, in response
to cell selection events. Doesn't it make more sense
to just add the listeners once to the respective
column editors during initialization, and just leave
them in place? What in your design requires you to
be doing so much adding and removing of listeners?

>I reviewed several examples and could not find a
>difference to my code.

Does the example code also add and remove listeners so
frequently and under the same circumstances? Which
examples are you referring to? I just did a search
of the entire "samples" folder for "editlist" and
found nothing for "removeEditListener".

In fact, in most cases, the "addEditListener()" method
is called in the "jbInit()" method, and in the
remaining cases, the method is in initializing code:
there's really no indication given in any of these
examples that one should be swapping in and out
edit listeners in the manner you describe above.

>The code is kinda complex so I won't post it here
>(it's simply too much and nobody would read it I guess).

Is it unnecessarily complex?


Paul Furbacher [TeamB]

Save time, search the archives:
info.borland.com/newsgroups/ngsearch.html

Is it in Joi Ellis's Faq-O-Matic?
www.visi.com/~gyles19/fom-serve/cache/1.html

Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
 

{smallsort}

Re:TableCellEditor EventListenerList mechanism does not work with JBuilder9

Alexander Pohl wrote:
Quote
The described code is nothing more than a copy of the TableCellEditor sample
code from the Borland Help, ....

>Does the example code also add and remove listeners so
>frequently and under the same circumstances? Which
>examples are you referring to? I just did a search
>of the entire "samples" folder for "editlist" and
>found nothing for "removeEditListener".

Yes, it does. Any example I found was just working this way and everybody
seems to have copied the Borland example code, which causes this behaviour.
Sorry to be so pedantic, but I'm stumped.
I've searched the JBuilder 9 "samples"
directory for
removeedit*
removecell*
remove*listener
and find no examples of what you
seem to be referring to. I've
searched through the on-line Help
for JBuilder 9, but don't find any
mention in the context of a tutorial
or example.
Can you specifically point to the project
directory or Help page (quote the URL in
the status bar) of the example in
the JBuilder 9 distribution to which
you are referring?
I'd appreciate it if you could do this ...
that is, if you have the time.
Thanks.
--
Paul Furbacher (TeamB)
Save time, search the archives:
www.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
www.visi.com/~gyles19/fom-serve/cache/1.html
Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
 

Re:TableCellEditor EventListenerList mechanism does not work with JBuilder9

Hi Paul,
at www-106.ibm.com/developerworks/java/library/j-jtable/ you will
find an example project. The implementation of my code is the same.
It follows the example code of Sun's Java2 documentation
(java/api/javax/swing/event/EventListenerList.html) as listed below:
EventListenerList listenerList = new EventListenerList();
FooEvent fooEvent = null;
public void addFooListener(FooListener l) {
listenerList.add(FooListener.class, l);
}
public void removeFooListener(FooListener l) {
listenerList.remove(FooListener.class, l);
}
// Notify all listeners that have registered interest for
// notification on this event type. The event instance
// is lazily created using the parameters passed into
// the fire method.
protected void fireFooXXX() {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
// Process the listeners last to first, notifying
// those that are interested in this event
for (int i = listeners.length-2; i>=0; i-=2) {
if (listeners[i]==FooListener.class) {
// Lazily create the event:
if (fooEvent == null)
fooEvent = new FooEvent(this);
((FooListener)listeners[i+1]).fooXXX(fooEvent);
}
}
}
Regards,
Alexander Pohl
"Paul Furbacher" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote
Alexander Pohl wrote:

>The described code is nothing more than a copy of the TableCellEditor
sample
>code from the Borland Help, ....
>
>>Does the example code also add and remove listeners so
>>frequently and under the same circumstances? Which
>>examples are you referring to? I just did a search
>>of the entire "samples" folder for "editlist" and
>>found nothing for "removeEditListener".
>
>Yes, it does. Any example I found was just working this way and
everybody
>seems to have copied the Borland example code, which causes this
behaviour.

Sorry to be so pedantic, but I'm stumped.
I've searched the JBuilder 9 "samples"
directory for

removeedit*
removecell*
remove*listener

and find no examples of what you
seem to be referring to. I've
searched through the on-line Help
for JBuilder 9, but don't find any
mention in the context of a tutorial
or example.

Can you specifically point to the project
directory or Help page (quote the URL in
the status bar) of the example in
the JBuilder 9 distribution to which
you are referring?

I'd appreciate it if you could do this ...
that is, if you have the time.

Thanks.


--


Paul Furbacher (TeamB)

Save time, search the archives:
www.borland.com/newsgroups/ngsearch.html

Is it in Joi Ellis's Faq-O-Matic?
www.visi.com/~gyles19/fom-serve/cache/1.html

Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.