Java Swing Tutorial - Java FlowLayout LEFT








Syntax

FlowLayout.LEFT has the following syntax.

public static final int LEFT

Example

In the following code shows how to use FlowLayout.LEFT field.

import java.awt.Container;
import java.awt.FlowLayout;
/*ww w .jav  a2s  .  co  m*/
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

public class Main {

  public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(200, 200, 200, 200);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container content = aWindow.getContentPane();
    content.setLayout(new FlowLayout(FlowLayout.LEFT));
    content.add(new JButton("www.java2s.com"));
    content.add(new JLabel("www.java2s.com"));
    content.add(new JTextField("www.java2s.com"));
    aWindow.setVisible(true);
  }
}