JDK-4188854 : JPopupMenu not being redrawn properly if overlayed by a JOptionPane on WinNTSP3
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1998-11-10
  • Updated: 1998-11-18
  • Resolved: 1998-11-18
Related Reports
Duplicate :  
Description

Name: rk38400			Date: 11/10/98


JPopupMenu not being refreshed properly if overlayed by a JOptionPane on WinNTSP3
Especially the popup part that is under the dialog box is not refreshed

Note that this is the second time i suply this bug since i can't find my first
one in the base. Please in the confirmation mail give the bug id.

The following code shows up the problem :

// Author : Bruno Coudoin
//
// Show evidence that the popup is not refreshed properly under a joptionpane
// Note that if the frame is smaller and the popup goes beyond its limit, then 
// the problem do not appear

import javax.swing.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;

public class refreshBug extends JPanel implements ActionListener {
    JPopupMenu _jPopupMenu = new JPopupMenu();

    public void init() {
	JMenuItem menuItem;
	JButton jb = new JButton("Bring the popup here and select an item");

	this.add(jb, BorderLayout.CENTER);

	for(int i=1; i<10; i++) {
	    menuItem = new JMenuItem("Item "+i);
	    menuItem.addActionListener(this);
	    _jPopupMenu.add(menuItem);
	}

	MouseListener ml = new MouseAdapter() {
	    public void mouseReleased(MouseEvent e) {
		if(e.isPopupTrigger()) {
			_jPopupMenu.show(e.getComponent(),
					 e.getX(), e.getY());
		}
	    }
	};
	this.addMouseListener(ml);

	jb.addMouseListener(ml);

    }

    // An action is requested by the user    
    public void actionPerformed(java.awt.event.ActionEvent e) {

	JOptionPane.showMessageDialog(this,
				      "Check if there is some popup left under me\n"+
				      "if not, retry and let the popup appear where i am",
				      "WARNING",
				      JOptionPane.WARNING_MESSAGE);

	// Workaround
	_jPopupMenu.setVisible(false);
    }

    // Main
    public static void main(String[] args) {
	refreshBug applet = new refreshBug();
	JFrame frame = new JFrame();

	frame.addWindowListener(new WindowAdapter() {
	    public void windowClosing(WindowEvent e) {
		System.exit(0);
	    }
	});

	frame.setTitle("Popup refresh bug");
	frame.getContentPane().add(applet, BorderLayout.CENTER);
	applet.init();
	frame.setSize(400,400);
	Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
	frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
	frame.setVisible(true);
    }

}
(Review ID: 42235)
======================================================================

Comments
WORK AROUND Name: rk38400 Date: 11/10/98 Found any ======================================================================
11-06-2004