Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4188854
Votes 0
Synopsis JPopupMenu not being redrawn properly if overlayed by a JOptionPane on WinNTSP3
Category java:classes_swing
Reported Against 1.2rc1
Release Fixed
State 11-Closed, duplicate of 4189244, bug
Priority: 4-Low
Related Bugs 4189244
Submit Date 10-NOV-1998
Description




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)
======================================================================
Work Around




Found any
======================================================================
Evaluation
N/A
Comments
  
  Include a link with my name & email   

Submitted On 16-NOV-1998
coudobp
Same as bug ID 4189244


Submitted On 12-MAY-1999
mhholmes
I ran into this bug, and I found a workaround:  
After the dialog is dismissed, call repaint() on 
the JFrame that contains the menu bar.  
(Actually, I call repaint() on both the JFrame and 
its contentPane (see JFrame.getContentPane()).  
I'm not sure if both repaints are necessary, or 
which one  of them is the one that does the 
trick.)



PLEASE NOTE: JDK6 is formerly known as Project Mustang