JDK-4049083 : PopupMenu.show() blocks on Windows 95 but not Solaris
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.1
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_95
  • CPU: x86
  • Submitted: 1997-05-01
  • Updated: 2006-10-13
Description
PopupMenu.show() blocks on Windows 95 in JDK 1.1.1, but not on Solaris under either 1.1.1 or 1.1.2 as of April 30.

I can think of no great reason it should block, but whether or not it does, it should be consistent among the platforms.


Here is a sample program -

import java.awt.*;

public class XX {

  public static void main(String[] args){
    Frame f = new Frame();
    Panel p = new Panel();
    p.setSize(200,200);
    p.setLayout(null);
    f.add("Center",p);
    f.pack();
    f.setVisible(true);
    PopupMenu m = new PopupMenu();
    m.add("Item A");
    m.add("Item B");
    p.add(m);
    m.show(p,50,50);
    System.out.println("Show has returned");
  }

}

On Solaris, "Show has returned" prints immediately (while PopupMenu is still
showing).
On Windows, "Show has returned" does not print until after an item is selected
(or the popup is dismissed).

I have reverified that this bug still exists in 1.1.5.



thomas.lichtenberg@Eng 1998-03-04
Also on WindowsNT. The sample program above is a usable test case. a similar one is attached. I added keyword pjava as this bug also affects Personal Java

Comments
EVALUATION Well., it is an interesting problem :) We could make this call either blocking or not, but we will break some applications anyway :( So, what is the best way? perhaps, will not fix :( Need to think about this.
09-10-2006

EVALUATION .
09-10-2006

WORK AROUND If you want consistent non-blocking behavior, create a thread, whose run method does nothing but show the popupmenu. For consistent blocking behavior, no workaround is possible, as there is no isShowing() method on PopupMenus. ============================================================================ The workaround above was supplied by the customer, not the Java Software Division. It is not correct. Modifying the GUI on threads other than the Event Dispatch Thread is not supported in AWT or Swing. The issues discussed in the following tutorials about threads and the use of invokeLater and invokeAndWait in Swing also apply to AWT. Threads and Swing http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html How to Use Threads http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html There is also a series of Swing Connection articles which explain in detail the threading issues when using Swing. http://java.sun.com/jfc/tsc/articles/index.html - Swing Threads 1, 2, 3, and Swing Worker Update. ###@###.### 2003-03-20
20-03-2003

EVALUATION Amy -- can you give an indication of which is correct? We need a test case. mike.bronson@eng 1998-01-22 ======================================================================= Tested on Windows NT 4.0 SP5 with JDK 1.3RA and the difference is still seen between the Solaris and Windows. sandeep.konchady@Eng 1999-12-08 It blocks on Win32 because the ::TrackPopupMenu(...) Win32 API is used. So to be consistent the Solaris implementation should block. richard.ray@eng 2000-10-26
08-12-1999