JDK-4842599 : REGRESSION: JPopupMenu not Hidden Properly After Iconified and Deiconified
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version:
    4.4,4.5,1.3.1,1.4.0,1.4.1,1.4.2_08,5.0,6 4.4,4.5,1.3.1,1.4.0,1.4.1,1.4.2_08,5.0,6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS:
    generic,linux,windows_nt,windows_2000,windows_xp generic,linux,windows_nt,windows_2000,windows_xp
  • CPU: generic,x86
  • Submitted: 2003-04-03
  • Updated: 2006-02-20
  • Resolved: 2005-08-21
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.
Other JDK 6
5.0u8Fixed 6 b49Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
Name: jk109818			Date: 04/03/2003


FULL PRODUCT VERSION :
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)


FULL OPERATING SYSTEM VERSION :
Windows 2000 Service Pack 3

A DESCRIPTION OF THE PROBLEM :
After a popup menu is shown partially outside the window
frame, minimize the window and then click the icon to show
the window again, the whole area of the pop menu will stay
opaque like a hanging application. And it will stay as long
as the same popup menu is triggered and shown totally
within the frame.

  To make it go away, you have to trigger it and show the
popup menu partially outside the window again.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the example code
2. Right mouse click somewhere near the window boundary
3. Minimize the window by clicking the minimize icon
4. Click the application icon to bring back the window

EXPECTED VERSUS ACTUAL BEHAVIOR :
The popup menu should disappear completely. But in the
example, the popup menu area will seem like application
hanging.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package com.tg.test;
import java.awt.event.*;
import javax.swing.*;

public class OutOfBoundPopupTest extends javax.swing.JFrame
{
  private JPopupMenu popupMenu;
  /** Creates new form OutOfBoundPopupTest */
  public OutOfBoundPopupTest()
  {
    initComponents();
    initUI();
  }
  
  private void initUI()
  {
    setTitle("Out of Bound PopupMenu Test");
    popupMenu = new JPopupMenu();
    JMenuItem menuItem1  = new JMenuItem("MenuItem Test 1");
    JMenuItem menuItem2  = new JMenuItem("MenuItem Test 2");
    JMenuItem menuItem3  = new JMenuItem("MenuItem Test 3");
    JMenuItem menuItem4  = new JMenuItem("MenuItem Test 4");
    JMenuItem menuItem5  = new JMenuItem("MenuItem Test 5");
    JMenuItem menuItem6  = new JMenuItem("MenuItem Test 6");
    popupMenu.add(menuItem1);
    popupMenu.add(menuItem2);
    popupMenu.add(menuItem3);
    popupMenu.add(menuItem4);
    popupMenu.add(menuItem5);
    popupMenu.add(menuItem6);
    
    testPanel.addMouseListener(new MouseAdapter()
    {
      public void mouseReleased(MouseEvent e)
      {
        if(e.isPopupTrigger())
        {
          popupMenu.show(testPanel, e.getX(), e.getY());
        }
      }
    });
    
    setSize(200,100);
  }
  
  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  private void initComponents()
  {
    testPanel = new javax.swing.JPanel();

    addWindowListener(new java.awt.event.WindowAdapter()
    {
      public void windowClosing(java.awt.event.WindowEvent evt)
      {
        exitForm(evt);
      }
    });

    testPanel.setMaximumSize(new java.awt.Dimension(100, 40));
    testPanel.setMinimumSize(new java.awt.Dimension(100, 40));
    testPanel.setPreferredSize(new java.awt.Dimension(100, 40));
    getContentPane().add(testPanel, java.awt.BorderLayout.CENTER);

    pack();
  }
  
  /** Exit the Application */
  private void exitForm(java.awt.event.WindowEvent evt)
  {
    System.exit(0);
  }
  
  /**
   * @param args the command line arguments
   */
  public static void main(String args[])
  {
    new OutOfBoundPopupTest().show();
  }
  
  
  // Variables declaration - do not modify
  private javax.swing.JPanel testPanel;
  // End of variables declaration
  
}

---------- END SOURCE ----------

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

(Review ID: 181260) 
======================================================================

Comments
EVALUATION Name: azR10139 Date: 04/07/2003 This is an AWT bug, We are hiding the window that contains our popup when invoker's frame being iconified but after restoring of parent frame the window becames visible again. Here is the minimal testcase: -- AwtBug.java import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class AwtBug extends WindowAdapter { public void windowIconified(WindowEvent ev) { if(window != null) { System.out.println("Hiding window"); window.hide(); } } static public Window window = null; public static void main(String[] args) { Frame frame = new Frame("The parent"); frame.addWindowListener(new AwtBug()); window = new Window(frame); Button btn = new Button("Press to show window"); btn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { window.setSize(100, 100); window.setLocation(100, 100); window.show(); } }); frame.add(btn); frame.pack(); frame.show(); } } -- ###@###.### 04/07/2003 ====================================================================== Name: rpR10076 Date: 04/10/2003 The test that reproduces AWT bug behaves the same way with 1.3.1 and 1.3. The difference in original test case behaviour must be cause by the fact that before 1.3.1 Swing removed its popup menu on window iconification, while now its just hiding it. AWT comes to inconsistent state with this testcase: our code assumes that the window (or popup menu) is not visible after the owner is restored, hence no repainting. It seems that the native system restores child windows unconditionally. We'll need to investigate this in Tiger. ====================================================================== Looks like this bug can be fixed by intercepting WM_SHOWWINDOW message with lParam WM_PARENTSHOWING and disabling DefWindowProc call if the window has been hidden. ###@###.### 2005-06-24 15:57:01 GMT
24-06-2005

SUGGESTED FIX Which version of 1.5 is this targetted for ? ###@###.### 2005-06-20 14:58:15 GMT *** /net/sterna/export/vb157120/mt/webrev/src/windows/native/sun/windows/awt_Component.cpp- 2005-07-28 14:34:06.488461000 +0400 --- /net/sterna/export/vb157120/mt/webrev/src/windows/native/sun/windows/awt_Component.cpp 2005-07-28 14:34:06.096243000 +0400 *************** *** 459,464 **** --- 459,465 ---- jobject target = env->GetObjectField(peer, AwtObject::targetID); jboolean visible = env->GetBooleanField(target, AwtComponent::visibleID); + m_visible = visible; if (visible) { windowStyle |= WS_VISIBLE; *************** *** 858,868 **** --- 859,871 ---- void AwtComponent::Show() { + m_visible = true; ::ShowWindow(GetHWnd(), SW_SHOWNA); } void AwtComponent::Hide() { + m_visible = false; ::ShowWindow(GetHWnd(), SW_HIDE); } *** /net/sterna/export/vb157120/mt/webrev/src/windows/native/sun/windows/awt_Component.h- 2005-07-28 14:34:05.586538000 +0400 --- /net/sterna/export/vb157120/mt/webrev/src/windows/native/sun/windows/awt_Component.h 2005-07-28 14:34:05.472784000 +0400 *************** *** 161,166 **** --- 161,168 ---- virtual void GetInsets(RECT* rect) { VERIFY(::SetRectEmpty(rect)); } + + BOOL IsVisible() { return m_visible;}; /* * Enable/disable component *************** *** 651,656 **** --- 653,659 ---- UINT m_myControlID; /* its own ID from the view point of parent */ BOOL m_backgroundColorSet; BOOL m_dragged; /* in drag operation */ + BOOL m_visible; /* copy of Component.visible */ static BOOL sm_suppressFocusAndActivation; static HWND sm_realFocusOpposite; *** /net/sterna/export/vb157120/mt/webrev/src/windows/native/sun/windows/awt_Dialog.cpp- 2005-07-28 14:34:10.299608000 +0400 --- /net/sterna/export/vb157120/mt/webrev/src/windows/native/sun/windows/awt_Dialog.cpp 2005-07-28 14:34:10.236111000 +0400 *************** *** 323,328 **** --- 323,329 ---- } else { ::ShowWindow(GetHWnd(), SW_SHOW); } + m_visible = true; } void AwtDialog::CheckInstallModalHook() { *** /net/sterna/export/vb157120/mt/webrev/src/windows/native/sun/windows/awt_Frame.cpp- 2005-07-28 14:34:09.621660000 +0400 --- /net/sterna/export/vb157120/mt/webrev/src/windows/native/sun/windows/awt_Frame.cpp 2005-07-28 14:34:09.516186000 +0400 *************** *** 581,586 **** --- 581,587 ---- ::ShowWindow(hwnd, SW_RESTORE); } } + m_visible = true; } void *** /net/sterna/export/vb157120/mt/webrev/src/windows/native/sun/windows/awt_Window.cpp- 2005-07-28 14:34:08.921743000 +0400 --- /net/sterna/export/vb157120/mt/webrev/src/windows/native/sun/windows/awt_Window.cpp 2005-07-28 14:34:08.807672000 +0400 *************** *** 531,536 **** --- 531,537 ---- if (!done) { ::ShowWindow(GetHWnd(), nCmdShow); } + m_visible = true; env->DeleteLocalRef(target); } *************** *** 900,905 **** --- 901,916 ---- return AwtComponent::WmDestroy(); } + MsgRouting AwtWindow::WmShowWindow(BOOL show, UINT status) + { + if (show && (status == SW_PARENTOPENING)) { + if (!IsVisible()) { + return mrConsume; + } + } + return AwtCanvas::WmShowWindow(show, status); + } + /* * Override AwtComponent's move handling to first update the * java AWT target's position fields directly, since Windows *** /net/sterna/export/vb157120/mt/webrev/src/windows/native/sun/windows/awt_Window.h- 2005-07-28 14:34:08.525219000 +0400 --- /net/sterna/export/vb157120/mt/webrev/src/windows/native/sun/windows/awt_Window.h 2005-07-28 14:34:08.489054000 +0400 *************** *** 108,113 **** --- 108,114 ---- virtual MsgRouting WmCreate(); virtual MsgRouting WmClose(); virtual MsgRouting WmDestroy(); + virtual MsgRouting WmShowWindow(BOOL show, UINT status); virtual MsgRouting WmDDEnterFullScreen(HMONITOR monitor); virtual MsgRouting WmDDExitFullScreen(HMONITOR monitor); virtual MsgRouting WmMove(int x, int y);
20-06-2005

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
22-09-2004