I am looking if it is possible to add an item (“about” the application) in the Winwdows system menu of the current JFrame.
As it is suggested in that answer, I know that it could be possible to tweak the menu via JNI/JNA and the windows API with GetSystemMenu(), but I am looking if it is possible in plain vanilla Java/Swing.
I have found something telling it should be possible in that forum thread:
this prior to creating a JFrame
JFrame.setDefaultLookAndFeelDecorated(true);
then, before adding anything to the frame, iterate the frame’s components,
looking for the JMenu. When found, add your ‘about’ menuItemjust tested, works fine.
Alas, a whole sscce is not provided, and I did not manage to make it work in my code. When breakpointing just after the windows creation prior adding the components, I see no JMenu. Neither at the first level (JRootPane) nor in the successively embedded components (JPanel, JLayeredPane).
If it matters, I am dealing with Java 6/7 on WinXP and Win7, the window is created as a new JFrame("some title") and I am using the native look & feel UIManager.getSystemLookAndFeelClassName().
The JMenu component does exist when using the cross-platform look and feel. The hierarchy of components is:
Unfortunately, when using the Windows look and feel, Java doesn’t know about the title bar at all. You’re probably stuck either using JNA or a different laf.