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

Embedded resizing of children in JLayeredPane without initiating setBounds()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.4.2
    • client-libs



      Name: rmT116609 Date: 09/09/2004


      A DESCRIPTION OF THE REQUEST :
      All other containers seem to process the change in size of a parent automatically. However, JLayeredPane does not:

      1) No child addded to a JLayeredPane appears unless it has had its bounds explicitly set by a call to setBounds().

      2) Once the parent has been resized, the children retain their original bounds. (ie. no event triggered layout adjustment is done....)

      JUSTIFICATION :
      While it can be tested for and caught, the necessary code required to calculate and maintain all child component's aspects within a JLayeredPane is fairly large and time consuming.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Add a component as CENTER to a BorderLayout and it will consume as much available space as possible without explicitly setting the component's bounds.

      Resizing a JFrame , JWindow or JPanel applies the current LayoutManager's behaviour and rules to the contained components ie..they are automatically resized.
      ACTUAL -
      Add a component to a JLayeredPane without a specifically setting the component's bounds will prevent the JLayeredPane from displaying the component.

      Resizing a JLayered pane has no affect on the contained components. Almost as if the child components are unaware of the change....

      ---------- BEGIN SOURCE ----------
      public static void main(String[] args)
      {
      javax.swing.JFrame tFrame = new javax.swing.JFrame("LAYER TEST");
              tFrame.setDefaultCloseOperation(tFrame.EXIT_ON_CLOSE);
              
              javax.swing.JLayeredPane layerPane = new javax.swing.JLayeredPane();
              
              tFrame.getContentPane().add(layerPane, java.awt.BorderLayout.CENTER);
              //JPanel - no bounds set...
              javax.swing.JPanel jp = new javax.swing.JPanel(new java.awt.BorderLayout(5, 5));
              jp.add(new javax.swing.JButton("Some Button"), java.awt.BorderLayout.CENTER);
              layerPane.add(jp, layerPane.DEFAULT_LAYER, -1);
              tFrame.setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize());
              tFrame.setVisible(true);
      }

      ABOVE displays no button.

      Add line:
      jp.setBounds(0, 0, 640, 480);

      and the panel/button is rendered.... changeing the size of the window arround will not resize these components.
      ---------- END SOURCE ----------


      (Incident Review ID: 301354)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: