import javax.swing.*;
 import java.awt.*;
 import java.awt.event.*;

 public class FlowLayoutTest extends JFrame implements ActionListener
 {
 private JButton B[];
 private Container c;

 public FlowLayoutTest(String s)
 {
 super(s);
 setLayout(new FlowLayout());
 B=new JButton[3];
 B[0]=new JButton("Left");
 B[1]=new JButton("Middle");
 B[2]=new JButton("Right");
 for(int i=0;i<B.length;i++)
 {
 B[i].addActionListener(this);
 add(B[i]);
 }
 }

 public void actionPerformed(ActionEvent e)
 {
 int position=FlowLayout.LEFT;;
 if(e.getSource()==B[0])
 {
 position=FlowLayout.LEFT;
 }
 else if(e.getSource()==B[1])
 {
 position=FlowLayout.CENTER;
 }
 else if(e.getSource()==B[2])
 {
 position=FlowLayout.RIGHT;
 }
 setLayout(new FlowLayout(position));
 validate();
 }
      public static void main(String[] args)
      {
        FlowLayoutTest f = new FlowLayoutTest("Flow Layout formatting for Graphic User Interphase (GUI) testi");
        f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        f.setSize(800,500);
        f.setVisible(true);     
      }
 }
