United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6384552 REGRESSION: unknown window is created when the height of menu list is longer tha
6384552 : REGRESSION: unknown window is created when the height of menu list is longer tha

Details
Type:
Bug
Submit Date:
2006-02-11
Status:
Resolved
Updated Date:
2011-01-19
Project Name:
JDK
Resolved Date:
2006-03-20
Component:
client-libs
OS:
generic,windows_xp,windows,windows_2000
Sub-Component:
java.awt
CPU:
x86,generic
Priority:
P1
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:
6

Related Reports
Duplicate:
Duplicate:
Duplicate:
Relates:
Relates:

Sub Tasks

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.
                                     
2006-02-20
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 ----
                                     
2006-02-17
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).
                                     
2006-02-14



Hardware and Software, Engineered to Work Together