Displays six buttons arranged by the flow layout manager. - Java Swing

Java examples for Swing:FlowLayout

Description

Displays six buttons arranged by the flow layout manager.

Demo Code

import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JFrame;

public class Main extends JFrame {

  public Main() {
    super("Alphabet");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    setSize(360, 120);/* w  w w .  j  a  va 2  s.co m*/
    FlowLayout lm = new FlowLayout(FlowLayout.LEFT);
    setLayout(lm);
    JButton a = new JButton("A");
    JButton b = new JButton("B");
    JButton c = new JButton("C");
    JButton d = new JButton("D");
    JButton e = new JButton("E");
    JButton f = new JButton("F");
    add(a);
    add(b);
    add(c);
    add(d);
    add(e);
    add(f);
    setVisible(true);
  }

  public static void main(String[] arguments) {
    Main frame = new Main();
  }
}

Related Tutorials