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

Method BorderLayout.getLayoutComponent(Container target, Object constraints) behaves unexpectedly

    XMLWordPrintable

Details

    • b67
    • generic
    • generic

    Description

      According to specification for java.awt.BorderLayput.getLayoutComponent(Container target, Object constraints)
      passed target param is "the Container using this BorderLayout", so if container that does not use this layout is passed, then null is expected to be returned
      -------------------------------------------------------------
      Parameters:
          constraints - the desired absolute position, one of CENTER, one of NORTH, SOUTH, EAST, WEST
          target - the Container using this BorderLayout
      -------------------------------------------------------------
      but actually component that was passed to method addLayoutComponent(Component comp, Object constraints) using the same constraints is returned

      Here is an example:
      ----- Test.java ---------------------------------------------
      import javax.swing.*;
      import java.awt.*;

      public class Test {
          public static void main(String[] args) {
              final BorderLayout borderLayout = new BorderLayout();
              final Component componentToBeAdded = new JButton();
              borderLayout.addLayoutComponent(componentToBeAdded, BorderLayout.CENTER);
              final Component returnedComponent = borderLayout.getLayoutComponent(new JPanel(), BorderLayout.CENTER);
              System.out.println("returnedComponent = " + returnedComponent);
          }
      }
      ----------------------------------------------------------
      dmitry.bessonov@russia 2005-04-19 13:16:54 GMT

      Attachments

        Issue Links

          Activity

            People

              dav Andrei Dmitriev (Inactive)
              dbessono Dmitry Bessonov
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: