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

public class MainFrame3 
extends JFrame 
implements ActionListener {
	
	public MainFrame3 (String caption) {
		super (caption);
	}
	
	public void initFrame() {
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setSize(600, 600);
		
		// 2 panels, left and rigth, added to a JSplitPane at the bottom
		JPanel left = new JPanel();
		Dimension leftDim = new Dimension(200, 200);
		left.setMinimumSize(leftDim);
		left.add(new JCheckBox("Check this"));
		
		JPanel right = new JPanel();
		// #1
		right.setLayout(new BorderLayout());
		right.add(new JLabel("Type here:"), BorderLayout.NORTH);
		JTextArea textArea = new JTextArea();
		textArea.setLineWrap(true);
		JScrollPane pane = new JScrollPane(textArea);
		right.add(pane);
		JButton button = new JButton("Press me");
		right.add(button, "South"); 
		button.addActionListener(this);
		
		// #2
		/* right.setLayout(new FlowLayout());
		right.add(new JLabel("Type here:"), BorderLayout.NORTH);
		JTextArea textArea = new JTextArea();
		textArea.setLineWrap(true);
		JScrollPane pane = new JScrollPane(textArea);
		// pane.setSize(200,200);  // set size of pane??
		// textArea.setSize(200, 200);  // how to set size of textArea??
		right.add(pane);
		JButton button = new JButton("Press me");
		right.add(button, "South"); 
		button.addActionListener(this); */
		
		// #3
		/* right.setLayout(new GridLayout(2, 2));
		right.add(new JLabel("Type here:"), BorderLayout.NORTH);
		JTextArea textArea = new JTextArea();
		textArea.setLineWrap(true);
		JScrollPane pane = new JScrollPane(textArea);
		right.add(pane);
		JButton button = new JButton("Press me");
		right.add(button, "South"); 
		button.addActionListener(this); */
		
		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!");
	}

}
