import java.awt.*; 
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*; 


public class MainFrame4 
extends JFrame 
implements ActionListener {
	
	public MainFrame4 (String caption) {
		super (caption);
	}
	
	public void initFrame() {
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setSize(1000, 1000);
		
		// 2 panels, left and right, added to a JSplitPane at the bottom
		
		// left panel
		JPanel left = new JPanel();
		left.setLayout(new BorderLayout());
		Dimension leftDim = new Dimension(200, 1000);
		left.setMinimumSize(leftDim);
		left.add(new JCheckBox("Check this"), BorderLayout.CENTER);
		
		// right panel, a GridLayout
		JPanel right = new JPanel();
		right.setLayout(new GridLayout(2, 2));
		
		JPanel topleft = new JPanel();
		topleft.setLayout(new BorderLayout());
		// right.add(new JLabel("Type here:"), BorderLayout.NORTH);
		JLabel label1 = new JLabel("  Type here ===>");
		label1.setFont(new Font("Serif", Font.BOLD, 26));
		label1.setForeground(Color.magenta);
		topleft.setBackground(Color.cyan);
		topleft.add(label1, "Center");
		// topleft.add(label1, BorderLayout.NORTH);
		right.add(topleft);
		
		JPanel topright = new JPanel();
		topright.setLayout(new BorderLayout());
		JTextArea textArea1 = new JTextArea();
		textArea1.setLineWrap(true);      // fix non-line wrapping
		textArea1.setWrapStyleWord(true);
		JScrollPane pane = new JScrollPane(textArea1);
		topright.add(pane);
		right.add(topright); 
		
		JPanel lowerleft = new JPanel();
		lowerleft.setLayout(new BorderLayout());
		JButton button = new JButton("Press me");
		button.setFont(new Font("ComicSansMS", Font.ITALIC, 18));
		lowerleft.setBackground(Color.orange);
		button.setForeground(Color.red);
		button.addActionListener(this);
		lowerleft.add(button);
		right.add(lowerleft);
		
		// lowerright #1
		JPanel lowerright = new JPanel();
		lowerright.setLayout(new BorderLayout());
		JTextArea textArea2 = new JTextArea();
		JScrollPane pane2 = new JScrollPane(textArea2);
		pane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
		lowerright.add(pane2);
		right.add(lowerright);  
		
		// lowerright #2
		// make lowerright JPanel a GridLayout:
		/* JPanel lowerright = new JPanel();
		lowerright.setLayout(new GridLayout(2, 1));
		JLabel label2 = new JLabel("  TYPE BELOW: ");
		label2.setFont(new Font("Cambria", Font.BOLD, 14));
		lowerright.add(label2);
		JTextArea textArea2 = new JTextArea();
		JScrollPane pane2 = new JScrollPane(textArea2);
		pane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
		lowerright.add(pane2);
		right.add(lowerright); */
		
		JSplitPane mainPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right);
		this.getContentPane().add(mainPane);
		
		
	}

	public void actionPerformed(ActionEvent event) {
		// System.out.println("Pressed button!");
		// OR
		JOptionPane.showMessageDialog(null, "Button Clicked!");
	}

}

