JDK-6919137 : JDK/JRE 1.6_11 unexpected windowing behavior in Solaris 10 using CDE environment
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6u17
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2010-01-22
  • Updated: 2011-02-16
  • Resolved: 2010-01-22
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Server VM (build 11.0-b16, mixed mode)
problems still exist in 1.6.0_17

ADDITIONAL OS VERSION INFORMATION :
SunOS cowboy 5.10 Generic_137137-09 sun4v sparc SUNW,Sun-Blade-T6320

EXTRA RELEVANT SYSTEM CONFIGURATION :
We are using solaris (as stated above) with go-global and the CDE environment.

A DESCRIPTION OF THE PROBLEM :
We have upgraded all or swing/awt UIs from 1.5.0_16 to 1.6.0_11 (problems still exist in 1.6.0_17). We now experience this issue:
- A JFrame is launched from the terminal (java ...)
- A modal dialog is brought to front then dismissed
- Instead of the jframe being brought to front **sometimes** the terminal comes to front.

I cannot reproduce this behavior in the 1.5 jre or on a windows platform.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a JFrame that displays a modal dialog then
 
- In Solaris using CDE launch the JFrame from a terminal
- Then launch the modal dialog
- Dismiss the modal dialog
- Verify that the terminal (or some window other than the JFrame) comes to
   front. (It sometimes does not happen on the first try)


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
In Java 5 the above steps would result in the JFrame (or the modal dialogs parent window) to be brought back to the front.
ACTUAL -
In Java 6 it is unpredictable which window further down in the visual stack will come to front when the dialog is dismissed.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import javax.swing.JTextArea;
import java.awt.GridBagConstraints;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;

public class BaseFrame extends JFrame{

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JPanel mainPanel = null;
	private JTextArea jTextArea = null;
	private JLabel jLabel = null;
	private JButton jButton = null;
	private JPanel buttonPanel = null;

	/**
	 * This is the default constructor
	 */
	public BaseFrame() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 *
	 * @return void
	 */
	private void initialize() {
		this.setSize(800, 600);
		this.setContentPane(getJContentPane());
		this.setTitle("This App Shows Buggy Windowing System!");
	}

	/**
	 * This method initializes jContentPane
	 *
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(new BorderLayout());
			jContentPane.add(getMainPanel(), BorderLayout.CENTER);
		}
		return jContentPane;
	}

	/**
	 * This method initializes mainPanel
	 *
	 * @return javax.swing.JPanel
	 */
	private JPanel getMainPanel() {
		if (mainPanel == null) {
			GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
			gridBagConstraints3.gridx = 0;
			gridBagConstraints3.gridy = 2;
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
			gridBagConstraints1.gridx = 0;
			gridBagConstraints1.gridy = 0;
			jLabel = new JLabel();
			jLabel.setText("Description of the Problem");
			jLabel.setFont(new Font("Dialog", Font.BOLD, 24));
			GridBagConstraints gridBagConstraints = new GridBagConstraints();
			gridBagConstraints.fill = GridBagConstraints.BOTH;
			gridBagConstraints.weighty = 1.0;
			gridBagConstraints.gridx = 0;
			gridBagConstraints.gridy = 1;
			gridBagConstraints.gridheight = 1;
			gridBagConstraints.weightx = 1.0;
			mainPanel = new JPanel();
			mainPanel.setLayout(new GridBagLayout());
			mainPanel.add(getJTextArea(), gridBagConstraints);
			mainPanel.add(jLabel, gridBagConstraints1);
			mainPanel.add(getButtonPanel(), gridBagConstraints3);
		}
		return mainPanel;
	}

	/**
	 * This method initializes jTextArea
	 *
	 * @return javax.swing.JTextArea
	 */
	private JTextArea getJTextArea() {
		if (jTextArea == null) {
			jTextArea = new JTextArea();
			jTextArea.setText("We have upgraded all or swing/awt UIs from 1.5.0_16 to 1.6.0_11 (problems still exist in 1.6.0_17). \nWe now experience this issue:\n- A JFrame is launched from the terminal (java ...)\n- A modal dialog is brought to front then dismissed\n- Instead of the jframe being brought to front **sometimes** the terminal comes to front.\n\nI cannot reproduce this behavior in the 1.5 jre or on a windows platform.");
			jTextArea.setPreferredSize(new Dimension(200, 112));
			jTextArea.setName("Description of the Problem");
		}
		return jTextArea;
	}

	/**
	 * This method initializes jButton
	 *
	 * @return javax.swing.JButton
	 */
	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setText("Launch Modal Dialog");
			jButton.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					//Show Modal Dialog
					ModalDialog mdlg = new ModalDialog(BaseFrame.this);
					mdlg.showDialog();
				}
			});
		}
		return jButton;
	}

	/**
	 * This method initializes buttonPanel
	 *
	 * @return javax.swing.JPanel
	 */
	private JPanel getButtonPanel() {
		if (buttonPanel == null) {
			GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
			gridBagConstraints2.fill = GridBagConstraints.BOTH;
			gridBagConstraints2.gridx = -1;
			gridBagConstraints2.gridy = -1;
			gridBagConstraints2.gridheight = 2;
			buttonPanel = new JPanel();
			buttonPanel.setLayout(new BorderLayout());
			buttonPanel.add(getJButton(), BorderLayout.CENTER);
		}
		return buttonPanel;
	}
	
	public static void main(String[] args) {
		BaseFrame frm = new BaseFrame();
		frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frm.setVisible(true);
	}
}


/******************************************************************
Seperate Class
******************************************************************/



import javax.swing.JPanel;
import java.awt.Frame;
import java.awt.BorderLayout;
import javax.swing.JDialog;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.JButton;
import javax.swing.JTextArea;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ModalDialog extends JDialog {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JPanel textPanel = null;
	private JPanel buttonPanel = null;
	private JButton jButton = null;
	private JTextArea jTextArea = null;

	/**
	 * @param owner
	 */
	public ModalDialog(Frame owner) {
		super(owner);
	}

	/**
	 * This method initializes this
	 *
	 * @return void
	 */
	private void initialize() {
		this.setSize(376, 200);
		this.setTitle("This is a Modal Dialog");
		this.setModal(true);
		this.setContentPane(getJContentPane());
	}
	
	public void showDialog(){
		initialize();
		this.setVisible(true);
	}
	/**
	 * Shuts down the window
	 */
	private void closeWindow() {
		setVisible(false);
		dispose();
	}

	/**
	 * This method initializes jContentPane
	 *
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(new BorderLayout());
			jContentPane.add(getTextPanel(), BorderLayout.CENTER);
			jContentPane.add(getButtonPanel(), BorderLayout.SOUTH);
		}
		return jContentPane;
	}

	/**
	 * This method initializes textPanel
	 *
	 * @return javax.swing.JPanel
	 */
	private JPanel getTextPanel() {
		if (textPanel == null) {
			textPanel = new JPanel();
			textPanel.setLayout(new BorderLayout());
			textPanel.add(getJTextArea(), BorderLayout.CENTER);
		}
		return textPanel;
	}

	/**
	 * This method initializes buttonPanel
	 *
	 * @return javax.swing.JPanel
	 */
	private JPanel getButtonPanel() {
		if (buttonPanel == null) {
			buttonPanel = new JPanel();
			buttonPanel.setLayout(new GridBagLayout());
			buttonPanel.add(getJButton(), new GridBagConstraints());
		}
		return buttonPanel;
	}

	/**
	 * This method initializes jButton
	 *
	 * @return javax.swing.JButton
	 */
	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setText("Dismiss Dialog");
			jButton.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					closeWindow();
				}
			});
		}
		return jButton;
	}

	/**
	 * This method initializes jTextArea
	 *
	 * @return javax.swing.JTextArea
	 */
	private JTextArea getJTextArea() {
		if (jTextArea == null) {
			jTextArea = new JTextArea();
			jTextArea.setText("Go ahead and dismiss me and see which window comes to front!");
		}
		return jTextArea;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"


---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Using java 1.5.X or older resolves the issue (which is not possible in our case).

SUPPORT :
YES

Release Regression From : 6u10
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.