Java Swing Tutorial - Java BorderLayout PAGE_END








Syntax

BorderLayout.PAGE_END has the following syntax.

public static final String PAGE_END

Example

In the following code shows how to use BorderLayout.PAGE_END field.

//from  w ww.j av a 2  s  .c o  m
import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class Main {
  public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel outerPanel = new JPanel(new BorderLayout());
    JPanel topPanel = new JPanel(new BorderLayout());
    JLabel label = new JLabel("Name:");
    JTextField text = new JTextField();
    topPanel.add(label, BorderLayout.PAGE_END);
    topPanel.add(text, BorderLayout.CENTER);
    outerPanel.add(topPanel, BorderLayout.AFTER_LAST_LINE);

    frame.add(outerPanel);
    frame.setSize(300, 200);
    frame.setVisible(true);

  }
}