Name: rl43681 Date: 02/04/2004
FULL PRODUCT VERSION :
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b31)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b31, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
I have an option pane in my application that has a sort of help button that is to bring up a modeless window with some reference information while working in the modal option dialog. It seems this does not work.
The parent/owner of the modeless dialog is null. If I try a JFrame instead of a modeless JDialog the frame can't even be dragged.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the test case below and observe how the scroll bar is not funcitonal in the final dialog after pressing the buttons to open the modal dialog. (JOptionPane)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It should eb possible to create functional modeless dialogs when an application has a modal dialog displayed.
ACTUAL -
The modeless dialogs or other frames are non-functional until the modal dialog is closed.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
// JDialog JScrollPane problem
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class DialogSP
{
public static void main(String [] args)
{
final JFrame f = new JFrame("DialogSP");
JButton button = new JButton("Press Me...");
f.getContentPane().add(button,BorderLayout.CENTER);
f.pack();
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
JOptionPane.showConfirmDialog(
f,
new OptionMessage(),
"Blah",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE );
}
});
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
public static final String msg = "Note this is not the same as Bug Id 4501654\n"
+"The modeless windows do not have the same parent as the modal dialog\n"
+"sdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\n"
+"sdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\n"
+"sdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\n"
+"sdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\n"
+"sdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\n"
+"sdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\n"
+"sdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\n"
+"sdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\n"
+"sdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\n"
+"sdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\nsdfg\n"
+"Note this is not the same as Bug Id 4501654\n"
+"The modeless windows do not have the same parent as the modal dialog\n";
}
class OptionMessage extends JPanel
{
OptionMessage()
{
JButton button = new JButton("Open JDialog then try to scroll...");
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
createModelessInfoDialog();
}
});
add(button);
JButton button2 = new JButton("Open JFramer then try to scroll or move the frame...");
button2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
createInfoFrame();
}
});
add(button2);
}
public void createModelessInfoDialog()
{
JDialog info = new ViewerDialog(
null,
"Modeless JDialog with null parent" );
info.pack();
info.setSize(640,480);
info.setModal( false );
info.setDefaultCloseOperation( JDialog.DISPOSE_ON_CLOSE );
info.setVisible( true );
}
public void createInfoFrame()
{
JFrame info = new ViewerFrame("JFrame" );
info.pack();
info.setSize(640,480);
info.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
info.setVisible( true );
}
}
class ViewerDialog extends JDialog
{
public ViewerDialog( Frame owner, String title )
{
super( owner, title );
JEditorPane dispArea;
dispArea = new JEditorPane("text/plain",DialogSP.msg);
dispArea.setEditable(false);
getContentPane().add(new JScrollPane(dispArea), BorderLayout.CENTER);
}
}
class ViewerFrame extends JFrame
{
public ViewerFrame( String title )
{
super( title );
JEditorPane dispArea;
dispArea = new JEditorPane("text/plain",DialogSP.msg);
dispArea.setEditable(false);
getContentPane().add(new JScrollPane(dispArea), BorderLayout.CENTER);
}
}
---------- END SOURCE ----------
(Incident Review ID: 235339)
======================================================================