Applet FlowLayout Example

By | May 16, 2011

The FlowLayout class puts components in a row, sized at their preferred size.

Creates a new flow layout manager with the indicated alignment and the indicated horizontal and vertical gaps. The hgap and vgap arguments specify the number of pixels to put between components.

import java.applet.*;
import java.awt.*;
  <applet code="FlowLayoutApplet" width=300 height=200>

public class test extends Applet

  public void init()
    setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));
    for (int i = 0; i < 20; i++)
    	add(new Button("Button" + i));

The output window look like this

Leave a Reply

Your email address will not be published. Required fields are marked *