I implemented the two missing methods in BasicInternalFrameUI, installKeyboardActions() and uninstallKeyboardActions().
I found out that the BasicInternalFrameUI installs an action called "showSystemMenu". Interesting is that the MetalInternalFrame seems to set this action to null again (Metal JInternalFrames have no system menu, this might be the reason for this), I guess that is why installKeyboardActions() is overridden in MetalInternalFrameUI. 2006-06-06 Roman Kennke <[EMAIL PROTECTED]> * javax/swing/plaf/basic/BasicInternalFrameUI.java (ShowSystemMenuAction): New class. (installKeyboardActions): Implemented. (uninstallKeyboardActions): Implemented. * javax/swing/plaf/metal/MetalInternalFrameUI.java (installKeyboardActions): Overridden to remove showSystemMenu action. /Roman
Index: javax/swing/plaf/basic/BasicInternalFrameUI.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java,v retrieving revision 1.36 diff -u -1 -0 -r1.36 BasicInternalFrameUI.java --- javax/swing/plaf/basic/BasicInternalFrameUI.java 16 May 2006 23:31:44 -0000 1.36 +++ javax/swing/plaf/basic/BasicInternalFrameUI.java 6 Jun 2006 12:15:30 -0000 @@ -31,56 +31,58 @@ independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ package javax.swing.plaf.basic; -import gnu.classpath.NotImplementedException; - import java.awt.AWTEvent; import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Cursor; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Insets; import java.awt.LayoutManager; import java.awt.LayoutManager2; import java.awt.Point; import java.awt.Rectangle; +import java.awt.event.ActionEvent; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.awt.event.MouseEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyVetoException; +import javax.swing.AbstractAction; +import javax.swing.ActionMap; import javax.swing.DefaultDesktopManager; import javax.swing.DesktopManager; import javax.swing.JComponent; import javax.swing.JDesktopPane; import javax.swing.JInternalFrame; import javax.swing.KeyStroke; import javax.swing.LookAndFeel; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.border.AbstractBorder; import javax.swing.event.InternalFrameEvent; import javax.swing.event.InternalFrameListener; import javax.swing.event.MouseInputAdapter; import javax.swing.event.MouseInputListener; +import javax.swing.plaf.ActionMapUIResource; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.InternalFrameUI; import javax.swing.plaf.UIResource; /** * This is the UI delegate for the Basic look and feel for JInternalFrames. */ public class BasicInternalFrameUI extends InternalFrameUI { /** @@ -1079,20 +1081,37 @@ bSize, false); g.fill3DRect(b.width - bSize, cornerSize, bSize, b.height - 2 * cornerSize, false); g.translate(-x, -y); g.setColor(saved); } } /** + * This action triggers the system menu. + * + * @author Roman Kennke ([EMAIL PROTECTED]) + */ + private class ShowSystemMenuAction + extends AbstractAction + { + public void actionPerformed(ActionEvent e) + { + if (titlePane != null) + { + titlePane.showSystemMenu(); + } + } + } + + /** * The MouseListener that is responsible for dragging and resizing the * JInternalFrame in response to MouseEvents. */ protected MouseInputAdapter borderListener; /** * The ComponentListener that is responsible for resizing the JInternalFrame * in response to ComponentEvents from the JDesktopPane. */ protected ComponentListener componentListener; @@ -1219,23 +1238,31 @@ && contentPane.getBackground() instanceof UIResource) { contentPane.setBackground(null); } } /** * This method installs the keyboard actions for the JInternalFrame. */ protected void installKeyboardActions() - throws NotImplementedException { - // FIXME: Implement. + ActionMapUIResource am = new ActionMapUIResource(); + am.put("showSystemMenu", new ShowSystemMenuAction()); + + // The RI impl installs the audio actions as parent of the UI action map, + // so do we. + BasicLookAndFeel blaf = (BasicLookAndFeel) UIManager.getLookAndFeel(); + ActionMap audioActionMap = blaf.getAudioActionMap(); + am.setParent(audioActionMap); + + SwingUtilities.replaceUIActionMap(frame, am); } /** * This method installs the Components for the JInternalFrame. */ protected void installComponents() { setNorthPane(createNorthPane(frame)); setSouthPane(createSouthPane(frame)); setEastPane(createEastPane(frame)); @@ -1302,23 +1329,24 @@ componentListener = null; borderListener = null; internalFrameListener = null; glassPaneDispatcher = null; } /** * This method uninstalls the keyboard actions for the JInternalFrame. */ protected void uninstallKeyboardActions() - throws NotImplementedException { - // FIXME: Implement. + SwingUtilities.replaceUIActionMap(frame, null); + SwingUtilities.replaceUIInputMap(frame, JComponent.WHEN_IN_FOCUSED_WINDOW, + null); } /** * This method creates a new LayoutManager for the JInternalFrame. * * @return A new LayoutManager for the JInternalFrame. */ protected LayoutManager createLayoutManager() { return new InternalFrameLayout(); Index: javax/swing/plaf/metal/MetalInternalFrameUI.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalInternalFrameUI.java,v retrieving revision 1.7 diff -u -1 -0 -r1.7 MetalInternalFrameUI.java --- javax/swing/plaf/metal/MetalInternalFrameUI.java 27 Oct 2005 09:50:58 -0000 1.7 +++ javax/swing/plaf/metal/MetalInternalFrameUI.java 6 Jun 2006 12:15:30 -0000 @@ -34,22 +34,24 @@ this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ package javax.swing.plaf.metal; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import javax.swing.ActionMap; import javax.swing.JComponent; import javax.swing.JInternalFrame; +import javax.swing.SwingUtilities; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicInternalFrameUI; /** * A UI delegate for the [EMAIL PROTECTED] JInternalFrame} component. */ public class MetalInternalFrameUI extends BasicInternalFrameUI { /** @@ -155,11 +157,27 @@ /** * Removes the listeners used. */ protected void uninstallListeners() { super.uninstallListeners(); frame.removePropertyChangeListener(IS_PALETTE, paletteListener); paletteListener = null; } + + /** + * Installs keyboard actions. This is overridden to remove the + * <code>showSystemMenu</code> Action that is installed by the + * <code>BasicInternalFrameUI</code>, since Metal JInternalFrames don't have + * a system menu. + */ + protected void installKeyboardActions() + { + super.installKeyboardActions(); + ActionMap am = SwingUtilities.getUIActionMap(frame); + if (am != null) + { + am.remove("showSystemMenu"); + } + } }