Example usage for java.awt BorderLayout BorderLayout

List of usage examples for java.awt BorderLayout BorderLayout

Introduction

In this page you can find the example usage for java.awt BorderLayout BorderLayout.

Prototype

public BorderLayout(int hgap, int vgap) 

Source Link

Document

Constructs a border layout with the specified gaps between components.

Usage

From source file:Main.java

public Main() {

    JButton btn1 = new JButton("Button1");
    JButton btn2 = new JButton("Button2");
    JButton btn3 = new JButton("Button3");
    JButton btn4 = new JButton("Button4");
    JButton btn5 = new JButton("Button5");
    JButton btn6 = new JButton("Button6");

    BorderLayout borderLayout = new BorderLayout(20, 30);

    setLayout(borderLayout);//from  w  ww.  j a va2s.  co  m

    add("North", btn1);
    add("West", btn2);
    add("Center", btn3);
    add("Center", btn4);
    add("South", btn5);
    add("East", btn6);

    System.out.println(borderLayout.toString());
}

From source file:Main.java

public Main() {

    JButton btn1 = new JButton("Button1");
    JButton btn2 = new JButton("Button2");
    JButton btn3 = new JButton("Button3");
    JButton btn4 = new JButton("Button4");
    JButton btn5 = new JButton("Button5");
    JButton btn6 = new JButton("Button6");

    BorderLayout borderLayout = new BorderLayout(20, 30);

    setLayout(borderLayout);//from w ww  .j  a  v a  2 s  .  c  o m

    add("North", btn1);
    add("West", btn2);
    add("Center", btn3);
    add("Center", btn4);
    add("South", btn5);
    add("East", btn6);

    System.out.println(borderLayout.getConstraints(btn1));
}

From source file:Main.java

public Main() {

    JButton btn1 = new JButton("Button1");
    JButton btn2 = new JButton("Button2");
    JButton btn3 = new JButton("Button3");
    JButton btn4 = new JButton("Button4");
    JButton btn5 = new JButton("Button5");
    JButton btn6 = new JButton("Button6");

    BorderLayout borderLayout = new BorderLayout(20, 30);

    setLayout(borderLayout);/*from  w  w w  . j  a  va 2 s  .com*/

    add("North", btn1);
    add("West", btn2);
    add("Center", btn3);
    add("Center", btn4);
    add("South", btn5);
    add("East", btn6);

    System.out.println(borderLayout.getLayoutAlignmentX(this));
}

From source file:Main.java

public Main() {

    JButton btn1 = new JButton("Button1");
    JButton btn2 = new JButton("Button2");
    JButton btn3 = new JButton("Button3");
    JButton btn4 = new JButton("Button4");
    JButton btn5 = new JButton("Button5");
    JButton btn6 = new JButton("Button6");

    BorderLayout borderLayout = new BorderLayout(20, 30);

    setLayout(borderLayout);/* ww  w  .j  a  va  2  s  .c o  m*/

    add("North", btn1);
    add("West", btn2);
    add("Center", btn3);
    add("Center", btn4);
    add("South", btn5);
    add("East", btn6);

    System.out.println(borderLayout.preferredLayoutSize(this));
}

From source file:Main.java

public Main() {

    JButton btn1 = new JButton("Button1");
    JButton btn2 = new JButton("Button2");
    JButton btn3 = new JButton("Button3");
    JButton btn4 = new JButton("Button4");
    JButton btn5 = new JButton("Button5");
    JButton btn6 = new JButton("Button6");

    BorderLayout borderLayout = new BorderLayout(20, 30);

    setLayout(borderLayout);/*from  w w w. j a  va 2s.c o m*/

    add("North", btn1);
    add("West", btn2);
    add("Center", btn3);
    add("Center", btn4);
    add("South", btn5);
    add("East", btn6);

    System.out.println(borderLayout.getLayoutAlignmentY(this));
}

From source file:Main.java

public Main() {
    JPanel inputPanel = new JPanel(new BorderLayout(3, 3));
    go.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                URL pageURL = new URL("http://www.google.com");
                HttpURLConnection urlConnection = (HttpURLConnection) pageURL.openConnection();
                int respCode = urlConnection.getResponseCode();
                String response = urlConnection.getResponseMessage();
                codeArea.setText("HTTP/1.x " + respCode + " " + response + "\n");
                int count = 1;
                while (true) {
                    String header = urlConnection.getHeaderField(count);
                    String key = urlConnection.getHeaderFieldKey(count);
                    if (header == null || key == null) {
                        break;
                    }/* w ww  . j a v a2s  . c  om*/
                    codeArea.append(urlConnection.getHeaderFieldKey(count) + ": " + header + "\n");
                    count++;
                }
                InputStream in = new BufferedInputStream(urlConnection.getInputStream());
                Reader r = new InputStreamReader(in);
                int c;
                while ((c = r.read()) != -1) {
                    codeArea.append(String.valueOf((char) c));
                }
                codeArea.setCaretPosition(1);
            } catch (Exception ee) {
            }
        }
    });
    inputPanel.add(BorderLayout.EAST, go);
    JScrollPane codeScroller = new JScrollPane(codeArea);
    add(BorderLayout.NORTH, inputPanel);
    add(BorderLayout.CENTER, codeScroller);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setSize(700, 500);
    this.setVisible(true);
}

From source file:Main.java

public Main() {
    JScrollPane talkPane = new JScrollPane(talkArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    JScrollPane inputPane = new JScrollPane(inputField, JScrollPane.VERTICAL_SCROLLBAR_NEVER,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    int gap = 10;
    setLayout(new BorderLayout(gap, gap));
    add(talkPane, BorderLayout.CENTER);
    add(inputPane, BorderLayout.SOUTH);
}

From source file:CardFrame.java

public CardFrame(String title) {
    setLayout(new BorderLayout(10, 10));
    nextCard.addActionListener(this);
    prevCard.addActionListener(this);
    firstCard.addActionListener(this);
    lastCard.addActionListener(this);

    Panel buttonsPanel = new Panel(new FlowLayout(FlowLayout.CENTER));
    buttonsPanel.add(firstCard);/*w ww  . jav a2  s .  co m*/
    buttonsPanel.add(prevCard);
    buttonsPanel.add(nextCard);
    buttonsPanel.add(lastCard);

    setCardLayout();
    add(BorderLayout.CENTER, cardPanel);
    add(BorderLayout.NORTH, buttonsPanel);
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 450, 300);/*from  w w  w. j av a  2 s . co  m*/

    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    JButton btnNewButton = new JButton("Click Me");
    btnNewButton.addActionListener(e -> doClick());
    contentPane.add(btnNewButton, BorderLayout.NORTH);
    jarFilesDB = new MyTreeModel();
    jarFilesDB.load(isAlpha);
    isAlpha = !isAlpha;
    jtree = new JTree(jarFilesDB);
    JScrollPane scrollPane = new JScrollPane(jtree);
    contentPane.add(scrollPane, BorderLayout.CENTER);
}

From source file:BorderLayoutPane.java

public BorderLayoutPane() {
    // Use a BorderLayout with 10-pixel margins between components
    this.setLayout(new BorderLayout(10, 10));
    for (int i = 0; i < 5; i++) { // Add children to the pane
        this.add(new JButton(borders[i]), // Add this component
                borders[i]); // Using this constraint
    }//from w w  w  . j a v a 2s  .  com
}