/*
 * 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 BoxLayout extends JFrame {
    
    private JPanel jpn1,jpn2;
    
    private JButton jbt1,jbt2,jbt3,jbt4,jbt5;
    

    public BoxLayout(String title) throws HeadlessException {
       
        super(title);
       
         this.setSize(600,300);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setLocationRelativeTo(null);
        this.setVisible(true);
        
        
        
       creatAndShow();
        
        
    }

    public void creatAndShow() {
//        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates
         jpn1 = new JPanel();
          jbt1 = new JButton("BOX LAYOUT");
          jbt2 = new JButton("X_AXIS");
          jbt3 = new JButton("Y_AXIS");
          jbt4 = new JButton("Het cho chua");
         jbt5 = new JButton("Thi xuong dong");
         jpn1.setLayout(new javax.swing.BoxLayout(jpn1,javax.swing.BoxLayout.Y_AXIS));
        
         jbt1.setForeground(Color.red);
         jpn1.add(jbt1);
         
         
         jbt2.setForeground(Color.blue);
         jpn1.add(jbt2);
         
        
         jbt3.setForeground(Color.ORANGE);
         jpn1.add(jbt3);
         
         jpn2 = new JPanel();
         jpn2.setLayout(new java.awt.FlowLayout());
         jpn2.add(jbt4);
         jpn2.add(jbt5);
         
         Container con = getContentPane();
         con.add(jpn1);
         
     }
    
    public static void main(String[] args) {
        
        new BoxLayout("MY WINDOW");
//        box.setSize(600,300);
//        box.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//        box.setLocationRelativeTo(null);
//        box.setVisible(true);
        
        
        
        
        
        
    }
    
    
    
    
}
