FlowLayout

The FlowLayout manager is the default Layout Manager for Applets and Panels. It is the most basic of the layout managers. It places components, left to right, within the container. If it runs out of room on one "line," it wraps around to the next line.

The only additional control that may be specified is the horizontal orientation -- LEFT, RIGHT, and CENTER (the default) -- and horizontal and vertical gap values. For details, see the class constructors.

Below is code for a basic Flow Layout:

import java.applet.Applet;
import java.awt.*;

public class step1 extends Applet{

// Illustrates Flow Layout

Frame outerBox = new Frame ( );

Button button1 = new Button ( "Button 1" );
Button button2 = new Button ( "Button 2" );
Button button3 = new Button ( "Button 3" );
Button button4 = new Button ( "Button 4" );
Button button5 = new Button ( "Button 5" );
Button button6 = new Button ( "Button 6" );

  public void init ( ){

    button1.setBackground ( Color.red );
    button2.setBackground ( Color.lightGray );
    button3.setBackground ( Color.cyan );
    button4.setBackground ( Color.yellow );
    button5.setBackground ( Color.green );
    button6.setBackground ( Color.orange );

    outerBox.setLayout ( new FlowLayout ( ) );
    outerBox.setBackground ( Color.white );
    outerBox. setFont (new Font ("Helvetica", Font.PLAIN, 18) );
    outerBox.resize (600, 500);

    outerBox.add ( button1 );
    outerBox.add ( button2 );
    outerBox.add ( button3 );
    outerBox.add ( button4 );
    outerBox.add ( button5 );
    outerBox.add ( button6 );

    outerBox.show( );

  } // end init

}// end step1 

Run the applet