// FlowLayoutDemo.java
// Demos FlowLayout alignments with an applet
// APPLET CODE="FlowLayoutDemo" HEIGHT=75 WIDTH=500
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class FlowLayoutDemo extends JApplet implements ActionListener {
	private Container c;
	private JButton left, center, right;
	private FlowLayout flow;

	public void init( ) {
		c = getContentPane( );
		flow = new FlowLayout( );
		c.setLayout( flow );

		left = new JButton( "Left" );
		left.addActionListener( this );	// registers the applet as the listener
		c.add( left );
		center = new JButton( "Center" );
		center.addActionListener( this );	// registers the applet as the listener
		c.add( center );
		right = new JButton( "Right" );
		right.addActionListener( this );	// registers the applet as the listener
		c.add( right );
	}

	public void actionPerformed( ActionEvent e ) {
		if ( e.getSource( ) == left ) flow.setAlignment( FlowLayout.LEFT );
		else if (e.getSource( ) == center ) flow.setAlignment( FlowLayout.CENTER );
		else flow.setAlignment( FlowLayout.RIGHT );
		
		flow.layoutContainer( c );
	}
}