I finally implemented something this weekend that had annoyed me for a long time, ever since in July 2008 I introduced the feature to detach DrJava’s Tabbed Panes and the Debugger and put them into separate windows.
These detached frames can have their own menu bar, but we didn’t have a menu bar set. That means that when you select those windows on the Mac, DrJava’s menu bar goes blank. That’s really annoying, because you first have to click on the main frame before you can use the menu. If you’re using the debugger, for example, you cannot just click on the “Debug” menu and select “Clear All Breakpoints”.
Note how in the first picture, when the detached Debugger window has the focus, there is no DrJava menu bar. The second picture shows the DrJava menu bar, which is only there when the main frame has the focus.
I had noticed this issue before, and I had even experimented with adding the main frame’s menu bar to the detached frames, but that failed, and I never filed a feature request for this until this Friday.
It’s surprisingly difficult to add the same menu bar to multiple frames. Each component can only have one parent, and that means there have to be separate
JMenuBar instances, separate
JMenu instances, all the way down to separate
JMenuItem instances. The only thing that can be shared are the actions the menu items invoke.
Instead of trying to use the same instance or cloning or copying the menu bar, I now create two completely separate structures that only share the actions. Then I have to make sure that they are kept in sync, but there aren’t many things that can change. The most obvious one are the recent files and projects.
I just noticed that menu items with check boxes aren’t synchronized across frames, so I still need to fix that tomorrow. But when I’m done with that, DrJava will be much more pleasant to use on the Mac. Check out these two new screenshots: Menu bars, as it should be, even when the Debugger or the Tabbed Panes have focus!
Does anyone except for me actually detach the tabbed panes and the debugger? I can’t work with them attached anymore…
The bugs I discovered late last night have now been fixed.