/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package SwingControl;

import java.awt.Color;
import java.awt.Container;
import java.awt.HeadlessException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author ta
 */
public class FlowLayout extends  JFrame{

    public FlowLayout(String title) throws HeadlessException {
        super(title);
        creatAndShow();
    }
    
    private JPanel jpn;
    private JButton jbt1,jbt2,jbt3,jbt4,jbt5;
    
    
    public void creatAndShow()
    {
       jpn= new JPanel();
       jbt1 = new JButton("FLOW LAYOUT");
       jbt2 = new JButton("Add các dòng");
       jbt3 = new JButton("Trên 1 dòng");
       jbt4 = new JButton("Het cho chua");
       jbt5 = new JButton("Thi xuong dong");
       
//       jpn.add(jbt1);
//        jpn.add(jbt2);
//         jpn.add(jbt3);
//          jpn.add(jbt4);
//           jpn.add(jbt5);
//           
 //       Container con = getContentPane();
//         con.add(jpn);
//        
        this.getContentPane().add(jbt1);
         this.getContentPane().add(jbt2);
         this.getContentPane().add(jbt3);
         this.getContentPane().add(jbt4);
         this.getContentPane().add(jbt5);
         
         this.getContentPane().setBackground(Color.red);
         this.getContentPane().setLayout(new java.awt.FlowLayout());
         

    
    }
    
    public static void main(String[] args) {
        FlowLayout layout = new FlowLayout("MY WINDOW");
        layout.setSize(600,100);
        layout.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        layout.setLocationRelativeTo(null);
        layout.setVisible(true);
    }
    
    
}
