Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6257333
Votes 0
Synopsis Method BorderLayout.getLayoutComponent(Container target, Object constraints) behaves unexpectedly
Category java:classes_awt
Reported Against
Release Fixed mustang(b67)
State 10-Fix Delivered, bug
Priority: 2-High
Related Bugs 6358402 , 4172932
Submit Date 19-APR-2005
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);
    }
}
----------------------------------------------------------
  xxxxx@xxxxx   2005-04-19 13:16:54 GMT
Work Around
N/A
Evaluation
There is no any sort of check if target Container is assigned with current instance of BorderLayout in code below. Seems that first parameter is never in use:
....
    public Component getLayoutComponent(Container target, Object constraints) {
	boolean ltr = target.getComponentOrientation().isLeftToRight();
        Component result = null;
....

  xxxxx@xxxxx   2005-04-22 11:19:54 GMT
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang