File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes border layout (MUGHAL) pls hlp !!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "border layout (MUGHAL) pls hlp !!!!" Watch "border layout (MUGHAL) pls hlp !!!!" New topic

border layout (MUGHAL) pls hlp !!!!

kaushik banerjee
Ranch Hand

Joined: Mar 11, 2001
Posts: 56
this is a piece of code taken from compiles & runs fine. what is escaping me is that can i add the constraints in the manner shown without paying heed to the case of the constraints . i had the notion that constraints could only be added as for example in this fashion-- BorderLayout.SOUTH . if not,will any case combination of the constraint constants work . also i believe that the constants NORTH,SOUTH,EAST,WEST,CENTER were static & one had to use either the class name or the object name with them . what do u guys say?
import java.awt.*;
public class MyFrame
public static void main(String[] a)
Window w = new Frame();
String[] s={"North","South","East","West","Center"};
for(int i=0;i<s.length;i++)>
w.add(new Button(s[i]),s[i]);
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Kaushik,
The case is VERY important. The BorderLayout happens to check for the strings:
North, South, Center, West, and East
If you use any other case (i.e., NORTH, north, NOrth, etc.) you will not get the desired result. If the string is not matched then Center is assumed!
Final static variables are also defined in BorderLayout and as Java convention are capitalized:
shadow liu
Ranch Hand

Joined: Mar 19, 2001
Posts: 33
These are some old method which should be replaced with 1.1 method.
From Class Container Doc:
public Component add(String name, Component comp)
Adds the specified component to this container. It is strongly advised to use the 1.1 method, add(Component, Object), in place of this method.

public void add(Component comp,Object constraints)
Adds the specified component to the end of this container. Also notifies the layout manager to add the component to this container's layout using the specified constraints object.

[This message has been edited by shadow liu (edited April 24, 2001).]
I agree. Here's the link:
subject: border layout (MUGHAL) pls hlp !!!!
It's not a secret anymore!