JDK-6353636 : Different behavior of JMenu and JPopupMenu
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 5.0
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-11-21
  • Updated: 2021-07-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
There are two methods for adding Action into JMenu and JPopupMenu:
1. JMenuItem add(new JMenuItem(Action))
2. JMenuItem add(Action)

In second case we create anonymous subclass of JMenuItem.
But java.beans.XMLEncoder could not persist properly this JMenuItem because it isn't JavaBean: there are no public empty constructor. And XMLEncoder (and XMLDecoder) could not create instance of private anonymous class.

Could you implement method add(Action) as simple shortcut to method add(new JMenuItem(Action))?

Comments
EVALUATION While it is indeed unfortunate that these behave differently, we can't change it as the JMenu(Action) calls back to a protected method. I'm reassigning to beans to see if Sergey can work around it in the encoder.
01-03-2006

EVALUATION XMLEncoder can't save JMenu because it can't create the instance of anonymous class
28-02-2006