File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BorderLayout

 
lstrite
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the correct way to add components to a container with BorderLayout? The book I read said the method was:
add(Component, String) where the string is like "North" etc.
But on a couple mock exams I took they had the parameters switched around and the question/answer indicated that it was the correct way to add to a Border Layout.
Can someone clarify this for me, are both of them correct ways to do it?
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When in doubt, consult the on line API:
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.

So this one is the one to use:
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.
Parameters:
  comp   - the component to be added.
  constraints   - an object expressing layout constraints for this component.

The Constraints object can be a String object like "North"...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic