Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5097499

setComponentZOrder must be over ridden for JFrame

XMLWordPrintable

      Changing the Z Order of components using setComponentZOrder method with Swing components results in component mix up. This occurs with all layouts. This is reproducible in all platforms with tiger rc build.

      Steps to reproduce:
      1. Run the attached code.
      2. Wait for 5 secs and the Z Order of a text field present in the JFrame is changed and repainted. After this, only the text field is displayed in the JFrame.
      3. Now move the mouse inside the frame. In can be seen that the buttons appear now. Type something and now the components overlap.

      The issue here is that the setComponentZOrder method called for JFrame, re-parents the JTextField. After the method call, JFrame will be parent of the JTextField instead of the JFrame's contentPane. So setComponentZOrder must be over ridden in JFrame, to add the component to the contentPane, similar to JFrame's add method.

            shickeysunw Shannon Hickey (Inactive)
            gramachasunw Girish Ramachandran (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: