Solaris MediumWeight Popup Bug

If the lightWeightPopupEnabled property is set to false on a Swing popup component (such as a JComboBox or JMenuBar), and the popup's dimensions are such that it fits completely within the bounds of the window which contains the component, then Swing uses an AWT heavyweight panel to display the popup (we call this a "MediumWeight" popup).

Unfortunately, there is currently a bug in the AWT on Solaris which prevents this MediumWeight popup from being displayed on top of all other components in the window. Therefore, it's possible for this MediumWeight popup to appear obscured if it's overlapped by a heavyweight component.

It turns out that this bug only occurs if the popup (the AWT Panel) is placed as a direct child of the window. If the popup is instead parented from an AWT Panel (which is inside the window), then the problem goes away. Therefore it's fairly easy to workaround by creating an AWT Panel above the RootPane in your JFrame or JDialog. Following is an example which extends JFrame to workaround the problem:


import java.awt.*;
import java.awt.event.*;
import com.sun.java.swing.*;

public class JFrameFix extends JFrame {
    Panel zorderPanel;

    public JFrameFix() {
        super();
    }

    public JFrameFix(String title) {
        super(title);
    }

    protected void setRootPane(JRootPane root) {
        if (zorderPanel == null) {
            zorderPanel = new Panel();
            zorderPanel.setLayout(new BorderLayout());
            boolean checkingEnabled = isRootPaneCheckingEnabled();
            try {
                setRootPaneCheckingEnabled(false);
                add(zorderPanel, BorderLayout.CENTER);
            }
            finally {
                setRootPaneCheckingEnabled(checkingEnabled);
            }
        }

        if(rootPane != null && zorderPanel != null) {
            zorderPanel.remove(rootPane);
        }

        rootPane = root;

        if(rootPane != null) {
            zorderPanel.add(rootPane, BorderLayout.CENTER);
        }
    }
}


 Last modified: Thu Feb 26 11:04:20 PST 1998