Java program to demonstrate FlowLayout

//Program to implement flow layout


Description


Java provides several Layout managers they are:


  • Border Layout
  • Card Layout
  • Grid Layout
  • Flow Layout
  • Box Layout
  • GridBag Layout
  • Group Layout
  • Spring Layout


This program demonstrates the concept of flow layout. Flow Layout is the default layout manager. It arranges each components from left to right in row by row manner. In this program a label, text box and a button is added to an applet window by using Flow Layout.


Program



//<applet code=LayFlow.class height=400 width=400></applet>
import java.awt.*;

import java.applet.*;

public class LayFlow extends Applet

{

public void init()

{

setLayout(new FlowLayout());

Label l=new Label("Label");

add(l);

TextField text=new TextField("Text Field");

add(text);

Button b=new Button("Button");

add(b);

}

}


Output


FlowLayout demonstration in Java
FlowLayout in Java

No comments: