Earlier this evening, I wrote: > > I have extended javax.swing.AbstractAction (call it MyAction), > instantiated MyAction with both a text label and an image icon in > the AbstractAction constructor. In the app I have added that one > instance to both a menu and a toolbar.
and, as sample code: > > Action myAction = new MyAction( testLabel, testIcon ); > > fileMenu.add( myAction ); > toolBar.add( myAction ); I then went on to gripe in question form that this was not behaving the way I expected. .... It turns out that I was wrong to complain that the code was not behaving as I expected, when, in reality, it was the *DOCUMENTATION* that was not behaving as expected. In the J2SE 1.4.1 JavaDoc for both JMenu.add(Action) and JToolBar.add(Action), the following wording appears: ============================= As of 1.3, this is no longer the preferred method for adding Actions to a container. Instead it is recommended to configure a control with an action using setAction, and then add that control directly to the Container. ============================= Once I figured out and followed this advice, the app behaved as expected. Problem solved. So I no longer have any complaints about the behavior of the API. Instead I now have the following complaints about the documentation: 1. Why aren't these methods deprecated? If I had seen that the methods were deprecated (which is flagged clearly in my IDE), I never would have used them in the first place! 2. What the heck is a "control"? This is not used as a technical term or class name elsewhere in the language spec or API JavaDoc. I finally just looked for the "setAction(Action)" methods in the index, which took two or three minutes by itself because the index for the letter "S" is just such a huge HTML file. Thus, a "control" is apparently any object that is an instance either of AbstractButton or of JComboBox. If there had been appropriate "@see" and "@link" documentation, the meaning of the recommendation would have been much clearer. Even with these complaints, though, I have to admit, I did not RTFM nearly as thoroughly has I should have before coming here with the question/complaint. -- Roger ____________________________________________________ To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm Be respectful! Clean up your posts before replying ____________________________________________________
