Name: rmT116609 Date: 08/25/2003
FULL PRODUCT VERSION :
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode)
java version "1.4.2_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06)
Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode)
Ive seen it with later versions of 1.4.2 also.
FULL OS VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
The closing of popped up menus in a frame, when the frame is inconified, works fine until you close a dialog at the same position the menu is popped up. After that, the menu is closed, when the frame is iconified, but after deiconifiing the frame a grey area is shown, where the popup menu was. The grey area can only be removed by opening a menu at the specific position again.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Take the test case.
1) Open Dialog1 via menu Open->Dialog1
2) Close the dialog. Don������t move the dialog!
3) Open the menu by clicking "open".
4) Iconify the frame - make sure, that the popup menu is still visible when doing that
5) Deiconify the frame
If you do the same with dialog2, which opens to the right of the popup, the problem doesn������t occur.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The menu is gone.
ACTUAL -
You will see a grey area where the popup menu was. The grey area is not just a redraw problem, because it disappears not before you open the menu again.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TestJavaBug {
/** Creates a new instance of TestJavaBug */
public TestJavaBug() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
TestFrame f = new TestFrame();
f.addWindowListener( new WindowAdapter()
{
public void windowClosing( WindowEvent we )
{
System.exit(0);
}
});
}
}
class TestFrame extends JFrame implements ActionListener
{
public TestFrame()
{
JPanel basePanel = new JPanel( new BorderLayout() );
getContentPane().add( basePanel, BorderLayout.CENTER );
// Create menu bar
JMenuBar menuBar = new JMenuBar();
setJMenuBar( menuBar );
JMenu menu = new JMenu( "Open" );
menuBar.add( menu );
JMenuItem mi1 = new JMenuItem( "Dialog 1" );
mi1.setActionCommand("1");
mi1.addActionListener( this );
menu.add( mi1 );
JMenuItem mi2 = new JMenuItem( "Dialog 2" );
mi2.setActionCommand("2");
mi2.addActionListener( this );
menu.add( mi2 );
// Create center panel (Colored, so that we can see the grey menu shadow)
JLabel l = new JLabel( "Frame" );
JPanel p = new JPanel();
p.add(l);
p.setBackground( Color.blue );
basePanel.add( p, BorderLayout.CENTER );
pack();
setSize( getWidth(), 2*getHeight() );
setVisible( true );
}
public void actionPerformed( ActionEvent ae )
{
if ( ae.getActionCommand().equals( "1" ) )
{
JDialog dialog = new TestDialog(TestFrame.this,1);
dialog.setBounds( getX(), getY(), dialog.getWidth() * 2, getHeight() );
dialog.validate();
}
else
{
JDialog dialog = new TestDialog(TestFrame.this,2);
dialog.setBounds( getX() + 200, getY(), dialog.getWidth() * 2, getHeight() );
dialog.validate();
}
}
}
class TestDialog extends JDialog implements ActionListener
{
public TestDialog( JFrame parent, int nr )
{
super(parent);
setModal( false );
setDefaultCloseOperation( JDialog.DO_NOTHING_ON_CLOSE );
addWindowListener( new WindowAdapter()
{
public void windowClosing( WindowEvent we )
{
close();
}
});
JTextField tf = new JTextField( "Dialog " + nr );
getContentPane().setLayout( new BorderLayout() );
getContentPane().add( tf, BorderLayout.CENTER );
JPanel buttonPanel = new JPanel();
JButton closeButton = new JButton( "Close" );
closeButton.setActionCommand( "close" );
closeButton.addActionListener( this );
buttonPanel.add( closeButton );
getContentPane().add( buttonPanel, BorderLayout.SOUTH );
pack();
setVisible( true );
}
private void close()
{
setVisible(false);
dispose();
}
public void actionPerformed( ActionEvent ae )
{
close();
}
}
---------- END SOURCE ----------
(Incident Review ID: 200450)
======================================================================