classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] FYI: actioncommand fixes


From: Roman Kennke
Subject: Re: [cp-patches] FYI: actioncommand fixes
Date: Fri, 15 Jul 2005 10:59:35 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050317)


This particular piece breaks one of my apps here.
Yes. It needs my other patch for AbstractButton to work correct in all
places.

I have applied all patches and still breaks my app. I get an actionCommand of null where "" is expected at the very least. If it still matters (I committed a fix in the meantime) I could try to boil this case down to a simple testcase.

The problem with this
new approach is that getActionCommand() now does return the correct
value but in javax.swing.DefaultButtonModel.setPressed() an ActionEvent
gets fired with only the actionCommand set (which may be null) without
asking the label. Any idea about that?
Yes this is the intended behavior.

To elaborate this a bit:
Create a JButton and its model like this: new JButton("foo").

Asking the JButton for its actioncommand will return "foo" (no real ac
set -> returns the label instead).

However if you retrieve the model and ask it instead it will return
null. The same goes with actionevents: If an actionevent is created from
within the buttonmodel then it will show null as its actioncommand.

Now I our buttons register themselves as ActionListener of their model.
A few days ago this ActionListener's actionPerformed implementation
simply changed the source of the ActionEvent from the model to the
button and dispatched the actionevent to the button's own
actionlisteners. This was troublesome because the ActionEvent's
actionCommand was set by the model (usually to null) and could not be
changed (there is no setter and the class' field is final). I found out
that the JDK does not work this way* and my fix was to simply create a
new ActionEvent for the button's actionlisteners which uses most of the
ActionEvent provided by the model.

I hope this makes sense.

This makes perfect sense. Still it does not work, but it seems that my problems come from both actionCommand and text beeing null, and the button should return something non-null nevertheless. I already committed a patch for that, I hope I did it right. I really should put together a testcase for this actionCommand thingy. I (and others) changed the behaviour of actionCommand handling several times and it seems that we never got it right. :-/

Ciao,
/Roman




reply via email to

[Prev in Thread] Current Thread [Next in Thread]