/*
 * 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 JSplitDmeo;

import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSplitPane;

/**
 *
 * @author I'msimple
 */
public class DemoJSplit {
    
    JFrame frame;
    JPanel jpnLeft,jpnRight;
    JSplitPane jsp00;
    JSplitPane jsp01;
    

    public DemoJSplit(String text) {
        
        initContainer();
        
        initComponent();
        
        setAction();
        frame.setTitle(text);
        frame.setVisible(true);
    }

    private void setAction() {
        
        
    }
    private void initContainer() {
          frame = new JFrame();
        frame.setLayout(new BorderLayout());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400,600);
        frame.setLocationRelativeTo(null);
    }

    private void initComponent() {
        jpnLeft = new JPanel();
        
        //Chinh kích thuoc cho panel
        jpnLeft.setPreferredSize(new Dimension(200, 0));
        jpnRight = new JPanel();
        jpnRight.setLayout(new BorderLayout());
        jsp00 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jpnLeft, jpnRight);
        jsp00.setOneTouchExpandable(true);
        
        
        //Ta chi jpnRight thanh 2 phan
        JPanel jpnTop = new JPanel();
        JPanel jpnBottom = new JPanel();
        jsp01 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jpnTop, jpnBottom);
        //Chinh kich thuoc jpnTop lon len
        jpnTop.setPreferredSize(new Dimension(0,200));
        jsp01.setOneTouchExpandable(true);
       
        
        
        //add cac giao dien
        frame.add(jsp00);
        jpnRight.add(jsp01,BorderLayout.CENTER);
     }

    
   public static void main(String[] args) {
        new DemoJSplit("Chia đôi màn hình");
    }
    
}
