Results 1 to 5 of 5

Thread: How to use BorderLayout in Java?

  1. #1
    Join Date
    Aug 2006
    Posts
    162

    How to use BorderLayout in Java?

    Hi friends.
    I have started doing the coding in Java from a month ago. I am not much used to with Java. Before that I completed the C++ which I thought is much easy than the Java programming language. In Java, after learning to create an form and modules, I am told to do the BorderLayout which is in Layout Manager example. I need some help from you guys. So please tell me how to use BorderLayout in Java.?? Please help me soon as possible.!!
    Technology is a way of organizing the universe so that man doesn't have to experience it.-- Max Frisch 1911 -1991

  2. #2
    Join Date
    Jul 2006
    Posts
    286

    Re: How to use BorderLayout in Java?

    Since you are new to the Java programming language, you should know the basic concepts of the Border Layout before using it in coding. A border layout lays out a container, arranging and resizing its components to fit in five regions. The five regions are : North, South, East, West and Center. Each region cannot contain more than one component. And you will have to use the corresponding constant for that like : NORTH, SOUTH, EAST, WEST AND CENTER respectively for the five regions.
    IF you hate me, please don't mention it. I know who hates me and who doesn't. You really do not have to make fun of people....

  3. #3
    Join Date
    Aug 2006
    Posts
    235

    Re: How to use BorderLayout in Java?

    You will have to use the constants while adding a component to a container with a border layout. The following sample of the coding explains the same :
    Code:
    Panel p = new Panel();
        p.setLayout(new BorderLayout());
        p.add(new Button("Demo"), BorderLayout.NORTH);
    Also look at the following coding where I have not mentioned the layout :
    Code:
    Panel p1 = new Panel();
        p1.setLayout(new BorderLayout());
        p1.add(new TextArea());
    In the above coding the border layout would be set to the center, because an absence of a string specification the same as the constant CENTER.
    3.2 (northwood)
    2gig ram
    ATI AIW X800xt 256mb
    Gigabyte GA-8knxp 875p Chipset
    Optiwrite 8X DVD Burner
    Win XP PRO Sp2 (Works Perfectly)
    2 SATA Raptor 74gig Raid 0
    2 7200 IDE 320gig HD

  4. #4
    Join Date
    Jul 2006
    Posts
    286

    Re: How to use BorderLayout in Java?

    In addition to the directions, the BorderLayout also supports the constants of the relative positioning. And the positioning constants are :
    P
    1. AGE_START,
    2. PAGE_END,
    3. LINE_START,
    4. LINE_END.

    If you are using the ComponentOrientation as ComponentOrientation.LEFT_TO_RIGHT in a container, then these constants map to NORTH, SOUTH, WEST, and EAST, respectively.
    IF you hate me, please don't mention it. I know who hates me and who doesn't. You really do not have to make fun of people....

  5. #5
    Join Date
    Nov 2008
    Posts
    996

    Re: How to use BorderLayout in Java?

    I have provided you the coding that is used in applet for the BorderLayout :
    Code:
    import java.awt.*;
     import java.applet.Applet;
    
     public class buttonBorLay extends Applet {
       public void init() {
         setLayout(new BorderLayout());
         add(new Button("North"), BorderLayout.NORTH);
         add(new Button("South"), BorderLayout.SOUTH);
         add(new Button("East"), BorderLayout.EAST);
         add(new Button("West"), BorderLayout.WEST);
         add(new Button("Center"), BorderLayout.CENTER);
       }
     }

Similar Threads

  1. Replies: 4
    Last Post: 04-09-2013, 11:04 PM
  2. Setting Of Java to The Point At Manual Java
    By winni in forum Software Development
    Replies: 4
    Last Post: 10-01-2011, 10:05 PM
  3. Comparison between core java and advanced java
    By Prashobh Mallu in forum Software Development
    Replies: 5
    Last Post: 19-01-2010, 10:57 AM
  4. Link List Example in Java Sample program in Java
    By trickson in forum Software Development
    Replies: 2
    Last Post: 04-08-2009, 08:23 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,261,748.08493 seconds with 17 queries