Results 1 to 4 of 4

Thread: BorderLayout

  1. #1
    oneself is offline Member
    Join Date
    Jul 2009
    Posts
    2
    Rep Power
    0

    Default BorderLayout

    I wish to divide my program into three particular sections/areas visible on the same program. The BorderLayout has its directions (NORTH, SOUTH, etc.). For example, I wish to include in the SOUTH section a particular form (like radio buttons, etc.). Do you use BorderLayout for this? What is the code to make use of it?

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    832
    Rep Power
    6

  3. #3
    MuslimCoder is offline Senior Member
    Join Date
    Jan 2009
    Posts
    119
    Rep Power
    0

    Default

    The Border Layout is the second is easiet Layout to use with Java, after the Flow Layout.

    * Unlike the other Layout's you have to use set the layout using Fileds.

    * if you have specified nothing in the NORTH, EAST, SOUTH, WEST then the CENTER uses the space.


    Java Code:
    import java.awt.BorderLayout;
    import javax.swing.JFrame;
    import javax.swing.JButton;
    
    public class KnowIslam extends JFrame
    {
      
    JButton button;
    public  void init()
    {
    
    button = new JButton("Islaam.com");
    
    add(button,BorderLayout.SOUTH);
    setTitle("Hello");
    setSize(200,200);
    setVisible(true);
    }
    
    public static void main(String args[])
    {
    KnowIslam app = new KnowIslam();
    app.init();
    }
    
    }
    Last edited by MuslimCoder; 08-06-2009 at 10:34 PM.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Read the tutorial linked above but don't believe the statements on how you should use GridBagLayout. I think that the biggest "a-ha!" moment for me with layouts was when I found out that you could nest JPanels in other JPanels, each using their own distinct layout and thus have the benefits of any and all the layouts in your GUI. Have fun and good luck.

Similar Threads

  1. Replies: 4
    Last Post: 02-16-2009, 09:52 PM
  2. BorderLayout Demo
    By Java Tip in forum SWT
    Replies: 0
    Last Post: 07-11-2008, 04:51 PM
  3. Help with BorderLayout
    By lenny in forum AWT / Swing
    Replies: 1
    Last Post: 07-31-2007, 07:26 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •