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

java.awt.Window.add() doesn't work correctly.

XMLWordPrintable

    • sparc
    • solaris_2.5



      Name: asC58863 Date: 08/12/97



      The java.awt.Window.add(Panel) method does not work correctly.
      This method should add the Panel to the Window.
      But if two Panel with BorderLayout added
      then only last one will be correctly rendered.

      Here is the test demonstrating the bug:

      -----------------BorderLayoutTest.java------------------------
      import java.awt.*;


      public class BorderLayoutTest {

         public static void main(String args[]) {

            Window window = new Window( new Frame());
            window.setLayout(new GridLayout(1, 2));
            window.setBackground(Color.white);


            BorderLayout layout = new BorderLayout();
            Panel[] littlePanel = new Panel[2];

            for (int i = 0; i < 2; i++ ) {
              littlePanel[i] = new Panel(layout);
              littlePanel[i].setBackground(new Color(i*230, 100, 100));
              littlePanel[i].add( "North", new Label("Panel N " + i + " with BorderLayout"));

      window.add(littlePanel[i]);
            }

            window.setSize(600,300);
            window.setVisible(true);

         }
      }
         
         
         
      ---------Output from the test---------------------

      this test renders correctly only the last Panel in the window.

      --------------------------------------------------
         
      ======================================================================

            Unassigned Unassigned
            asemidetsunw Alexei Semidetnov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: