@@ -0,0 +1,2999 @@
+package com.dw.swing;%0A%0Aimport javax.swing.*;%0Aimport java.awt.BorderLayout;%0Aimport java.awt.Container;%0Aimport java.awt.Dimension;%0A%0Apublic class BorderLayoutDemo %7B%0A%0Apublic static boolean RIGHT_TO_LEFT = false;%0A    %0A    public static void addComponentsToPane(Container pane) %7B%0A        %0A        if (!(pane.getLayout() instanceof BorderLayout)) %7B%0A            pane.add(new JLabel(%22Container doesn't use BorderLayout!%22));%0A            return;%0A        %7D%0A        %0A        if (RIGHT_TO_LEFT) %7B%0A            pane.setComponentOrientation(%0A                    java.awt.ComponentOrientation.RIGHT_TO_LEFT);%0A        %7D%0A        %0A        JButton button = new JButton(%22Button 1 (PAGE_START)%22);%0A        pane.add(button, BorderLayout.PAGE_START);%0A        %0A        //Make the center component big, since that's the%0A        //typical usage of BorderLayout.%0A        button = new JButton(%22Button 2 (CENTER)%22);%0A        button.setPreferredSize(new Dimension(200, 100));%0A        pane.add(button, BorderLayout.CENTER);%0A        %0A        button = new JButton(%22Button 3 (LINE_START)%22);%0A        pane.add(button, BorderLayout.LINE_START);%0A        %0A        button = new JButton(%22Long-Named Button 4 (PAGE_END)%22);%0A        pane.add(button, BorderLayout.PAGE_END);%0A        %0A        button = new JButton(%225 (LINE_END)%22);%0A        pane.add(button, BorderLayout.LINE_END);%0A    %7D%0A    %0A    /**%0A     * Create the GUI and show it.  For thread safety,%0A     * this method should be invoked from the%0A     * event dispatch thread.%0A     */%0A    private static void createAndShowGUI() %7B%0A        %0A        //Create and set up the window.%0A        JFrame frame = new JFrame(%22BorderLayoutDemo%22);%0A        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);%0A        //Set up the content pane.%0A        addComponentsToPane(frame.getContentPane());%0A        //Use the content pane's default BorderLayout. No need for%0A        //setLayout(new BorderLayout());%0A        //Display the window.%0A        frame.pack();%0A        frame.setVisible(true);%0A    %7D%0A    %0A    public static void main(String%5B%5D args) %7B%0A        /* Use an appropriate Look and Feel */%0A        try %7B%0A            //UIManager.setLookAndFeel(%22com.sun.java.swing.plaf.windows.WindowsLookAndFeel%22);%0A            UIManager.setLookAndFeel(%22javax.swing.plaf.metal.MetalLookAndFeel%22);%0A        %7D catch (UnsupportedLookAndFeelException ex) %7B%0A            ex.printStackTrace();%0A        %7D catch (IllegalAccessException ex) %7B%0A            ex.printStackTrace();%0A        %7D catch (InstantiationException ex) %7B%0A            ex.printStackTrace();%0A        %7D catch (ClassNotFoundException ex) %7B%0A            ex.printStackTrace();%0A        %7D%0A        /* Turn off metal's use bold fonts */%0A        UIManager.put(%22swing.boldMetal%22, Boolean.FALSE);%0A        %0A        //Schedule a job for the event dispatch thread:%0A        //creating and showing this application's GUI.%0A        javax.swing.SwingUtilities.invokeLater(new Runnable() %7B%0A            public void run() %7B%0A                createAndShowGUI();%0A            %7D%0A        %7D);%0A    %7D%0A%0A%7D%0A

add swing demo for borderLayout