Need to resize the window for program to work
===

Here is the code of my Layout class.

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

    public class Layout extends JFrame{
	private JButton lb;
	private JButton cb;
	private JButton pb;
	private FlowLayout layout;
	private Container container;
	
	public Layout() {
		super("The Title");
		layout = new FlowLayout();
		container = new Container();
		setLayout(layout);
		
		//*Left
		lb = new JButton("L");
		add(lb);
		lb.addActionListener(
			new ActionListener(){	
				public void actionPerformed(ActionEvent event){
					layout.setAlignment(FlowLayout.LEFT);
					layout.layoutContainer(container);
				}
			}
		);
		//*Center
				cb = new JButton("C");
				add(cb);
				cb.addActionListener(
					new ActionListener(){	
						public void actionPerformed(ActionEvent event){
							layout.setAlignment(FlowLayout.CENTER);
							layout.layoutContainer(container);
						}
					}
				);		
				//*Right
				pb = new JButton("R");
				add(pb);
				pb.addActionListener(
					new ActionListener(){	
						public void actionPerformed(ActionEvent event){
							layout.setAlignment(FlowLayout.RIGHT);
							layout.layoutContainer(container);
						}
					}
				);
	}
    }
I'm learning java through thenewboston youtube tutorials (this code is from [this][1] tutorial). But this one doesn't work like it should. When I click the right button (R) it should drag all the buttons to the right side of the window instantly. It doesnt. However when I click that right button and then forcibly resize the window then it do what it should. By adding setResizable(false) in the main method I cant resize the program so it doesnt work.
What have I done wrong?

Forgive me for my poor English btw.


  [1]: http://www.youtube.com/watch?v=DFQzFJqOSbA&feature=relmfu