aspose file tools*
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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "border layout (MUGHAL) pls hlp !!!!" Watch "border layout (MUGHAL) pls hlp !!!!" New topic
Author

border layout (MUGHAL) pls hlp !!!!

kaushik banerjee
Ranch Hand

Joined: Mar 11, 2001
Posts: 56
Hi,
this is a piece of code taken from khalid.it 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]);
w.pack();
w.setSize(250,250);
w.setVisible(true);
}
}
THX IN ADVANCE
Regards,
KAUSHIK
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:
BorderLayout.NORTH
BorderLayout.SOUTH
BorderLayout.CENTER
BorderLayout.WEST
BorderLayout.EAST
Regards,
Manfred.
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.
*******
HTH.

[This message has been edited by shadow liu (edited April 24, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: border layout (MUGHAL) pls hlp !!!!