JDK-6384552 : REGRESSION: unknown window is created when the height of menu list is longer tha
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P1
  • Status: Resolved
  • Resolution: Fixed
  • OS:
    generic,windows,windows_2000,windows_xp generic,windows,windows_2000,windows_xp
  • CPU: generic,x86
  • Submitted: 2006-02-11
  • Updated: 2011-01-19
  • Resolved: 2006-03-20
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.
JDK 6
6 b77Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
A DESCRIPTION OF THE REGRESSION :
Windows XP Professional SP1+
JDK VERSION:mustang b71(not on this entry form,please append it)

click the menubar , when the total height of menu items is longer than the window itself, an unknown window is created and displayed on the window's Taskbar.

REPRODUCIBLE TESTCASE OR STEPS TO REPRODUCE:
package testbug;

import java.awt.Dimension;

import javax.swing.*;

public class TestJMenubar extends JFrame {
    private JMenuBar menuBar = new JMenuBar();

    private JMenu menuFile = new JMenu();

    private JMenuItem menuFileExit = new JMenuItem();

    private JMenuItem jMenuItem1 = new JMenuItem();

    private JMenuItem jMenuItem2 = new JMenuItem();

    public TestJMenubar() {
        try {
            jbInit();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        this.setJMenuBar( menuBar );
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.getContentPane().setLayout( null );
        this.setSize( new Dimension(400, 50) );
        this.setTitle( "Menu" );
        menuBar.setAutoscrolls(true);
        menuFile.setText( "File" );
        menuFileExit.setText("Item");
        jMenuItem1.setText("long 1");
        jMenuItem2.setText("long 2");
        menuFile.add( menuFileExit );
        menuFile.add(jMenuItem1);
        menuFile.add(jMenuItem2);
        menuBar.add(menuFile);
    }

    public static void main(String[] argv){
            TestJMenubar bar = new TestJMenubar();
            bar.setVisible(true);
    }

}


RELEASE LAST WORKED:
5.0 Update 6

RELEASE TEST FAILS:
mustang-b70

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no extra window please.. at least prevent it from being displayed on taskbar.
ACTUAL -
it seems a new window is created and displayed on taskbar without any caption...

Release Regression From : 5.0u6
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

Comments
EVALUATION The fix suggested is based on the fact that each AWT window that shouldn't be shown on the taskbar has WS_POPUP style. For such windows we shouldn't set WS_EX_APPWINDOW style.
20-02-2006

SUGGESTED FIX src/windows/native/sun/windows/awt_PopupMenu.cpp src/windows/native/sun/windows/awt_Window.cpp src/windows/native/sun/windows/awt_Window.h ------- awt_PopupMenu.cpp ------- *** /tmp/sccs.UjaaMN Tue Feb 21 18:22:25 2006 --- awt_PopupMenu.cpp Tue Feb 21 16:42:10 2006 *************** *** 113,123 **** pt.y -= rctInsets.top; flags = TPM_LEFTALIGN | TPM_RIGHTBUTTON; } else { - ((AwtWindow*)awtOrigin)->SetFocusableWindow(TRUE); // for AwtWindow's focus hook ::SetForegroundWindow(awtOrigin->GetHWnd()); flags = TPM_NONOTIFY | TPM_RIGHTALIGN | TPM_RIGHTBUTTON | TPM_BOTTOMALIGN; } --- 113,122 ---- ------- awt_Window.cpp ------- *** /tmp/sccs.staOTN Tue Feb 21 18:22:26 2006 --- awt_Window.cpp Tue Feb 21 18:11:27 2006 *************** *** 118,127 **** --- 118,128 ---- // what's the best initial value? m_screenNum = -1; ms_instanceCounter++; m_grabbed = FALSE; + m_isFocusableWindow = TRUE; if (AwtWindow::ms_instanceCounter == 1) { AwtWindow::ms_hCBTFilter = ::SetWindowsHookEx(WH_CBT, (HOOKPROC)AwtWindow::CBTFilter, 0, AwtToolkit::MainThread()); *************** *** 1740,1759 **** PDATA pData; JNI_CHECK_PEER_GOTO(self, ret); window = (AwtWindow *)pData; if (IS_WIN2000) { ! if (!isFocusableWindow) { ! window->SetStyleEx(window->GetStyleEx() | WS_EX_APPWINDOW | AWT_WS_EX_NOACTIVATE); } else { window->SetStyleEx(window->GetStyleEx() & ~WS_EX_APPWINDOW & ~AWT_WS_EX_NOACTIVATE); } ! } - window->SetFocusableWindow(isFocusableWindow); - ret: env->DeleteGlobalRef(self); delete sfws; } --- 1741,1761 ---- PDATA pData; JNI_CHECK_PEER_GOTO(self, ret); window = (AwtWindow *)pData; + window->m_isFocusableWindow = isFocusableWindow; + if (IS_WIN2000) { ! if (!window->m_isFocusableWindow) { ! LONG isPopup = window->GetStyle() & WS_POPUP; ! window->SetStyleEx(window->GetStyleEx() | (isPopup ? 0 : WS_EX_APPWINDOW) | AWT_WS_EX_NOACTIVATE); } else { window->SetStyleEx(window->GetStyleEx() & ~WS_EX_APPWINDOW & ~AWT_WS_EX_NOACTIVATE); } ! } ret: env->DeleteGlobalRef(self); delete sfws; } ------- awt_Window.h ------- *** /tmp/sccs.JEaq1N Tue Feb 21 18:22:27 2006 --- awt_Window.h Tue Feb 21 18:11:34 2006 *************** *** 92,104 **** void SendComponentEvent(jint eventId); void SendWindowEvent(jint id, HWND opposite = NULL, jint oldState = 0, jint newState = 0); BOOL IsFocusableWindow(); - INLINE void SetFocusableWindow(BOOL isFocusableWindow) { - m_isFocusableWindow = isFocusableWindow; - } /* some helper methods about blocking windows by modal dialogs */ INLINE static HWND GetModalBlocker(HWND window) { return reinterpret_cast<HWND>(::GetProp(window, ModalBlockerProp)); } --- 92,101 ----
17-02-2006

EVALUATION This regression is caused by the fix for 5091224 (Non-focusable windows steal focus from desktop windows). In that fix an extended style WS_EX_APPWINDOW is added to every AWT toplevel window, and that leads to all the windows to appear on the taskbar. If WS_EX_APPWINDOW style is simply removed, then all the non-focusable frames will disappear from the taskbar because of another style WS_EX_NOACTIVATE. So we need to track what toplevel is (Frame, Dialog, Window) and set WS_EX_APPWINDOW only for those that must be displayed on the taskbar: frames, ownerless dialogs, probably something else (need to be checked).
14-02-2006