FIX: BorderLayout: Cannot Add To Layout: Unknown Constraint

ID: Q189066

The information in this article applies to:

SYMPTOMS

Trying to add a component using the BorderLayout as follows

   f.add(button,BorderLayout.CENTER)

generates the following message when trying to execute the Java Application:

   BorderLayout: Cannot add to layout : unknown constraint: Center

RESOLUTION

This problem is fixed with the Jvc.exe that ships with the SDK for Java versions 2.0x and later.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been corrected in the Jvc.exe that ships with the SDK for Java version 2.0x and later.

MORE INFORMATION

Steps to Reproduce Behavior

1. Create a Java Application as follows:

      import java.awt.*;
      import java.awt.event.*;
      import java.util.*;

      public class test
      {
         public static void main(String args[])
         {
            Frame f = new Frame();
            f.setLayout(new BorderLayout());
            Button b1=new Button();
            f.add(b1,BorderLayout.CENTER);
            System.out.println(">"+BorderLayout.CENTER+"<");
            System.out.println(">"+BorderLayout.WEST+"<");
            System.out.println(">"+BorderLayout.EAST+"<");
            System.out.println(">"+BorderLayout.NORTH+"<");
            System.out.println(">"+BorderLayout.SOUTH+"<");
          }
      }

2. If you compile this using Jvc.exe, which ships with Visual J++ 1.x,
   you will see the above mentioned message when trying to execute this
   application.

   -or-

   If you are running this as an applet, you will notice that the
   components do not appear in the Browser.

3. To fix the problem, try compiling the sample above with the Jvc.exe file
   that ships with the SDK for Java 2.0x and later.

REFERENCES

For more information on how to use the Jvc.exe of SDK for Java from within Visual J++, please see the following article in the Knowledge Base:

   ARTICLE-ID : Q183712
   TITLE      : HOWTO: Installation Instructions for SDK for Java

Additional query words: borderlayout control browser kbnokeyword
Version           : WINDOWS:1.0,1.1
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbfix

Last Reviewed: November 10, 1998