Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import javax.swing.*;
- public class DemoBorderLayout {
- public static void main(String args[]) {
- JFrame frame = new JFrame("Border Layout");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setSize(300, 200);
- JButton northButton = new JButton("North");
- JButton southButton = new JButton("South");
- JButton eastButton = new JButton("East");
- JButton westButton = new JButton("West");
- JButton centerButton = new JButton("Center");
- Container contentPane = frame.getContentPane();
- contentPane.setLayout(new BorderLayout());
- contentPane.add(northButton, BorderLayout.NORTH);
- contentPane.add(southButton, BorderLayout.SOUTH);
- contentPane.add(eastButton, BorderLayout.EAST);
- contentPane.add(westButton, BorderLayout.WEST);
- contentPane.add(centerButton, BorderLayout.CENTER);
- frame.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement