BorderLayout.BEFORE_LINE_BEGINS : BorderLayout « java.awt « Java by API






BorderLayout.BEFORE_LINE_BEGINS

 
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.BEFORE_LINE_BEGINS);
    topPanel.add(text, BorderLayout.CENTER);
    outerPanel.add(topPanel, BorderLayout.BEFORE_FIRST_LINE);

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

  }
}

   
  








Related examples in the same category

1.BorderLayout.BEFORE_FIRST_LINE
2.BorderLayout.CENTER
3.BorderLayout.EAST
4.BorderLayout.NORTH
5.BorderLayout.SOUTH
6.BorderLayout.WEST
7.new BorderLayout()