import java.awt.*;
import javax.swing.*;

public class Titanic extends JFrame {
    private JPanel panel;
    private JLabel movieLabel;
    private JLabel directorLabel;
    private JLabel actorLabel;
    private JLabel actressLabel;
    private JLabel moviePictureLabel;
    private Container contentPane;
    public Titanic() {
	super("Titanic"); // set the title to titanic;
	contentPane = getContentPane();
	setUpLabels(); // set up the labels, see the method below
	int col = 1;
	// create a panel with GridLayout
	panel = new JPanel(new GridLayout(0,col));
	// add labels to the panel
	panel.add(movieLabel);
	panel.add(directorLabel);
	panel.add(actorLabel);
	panel.add(actressLabel);
	// and panel to west side of the frame
	contentPane.add(panel, BorderLayout.WEST);
	// add moviePictureLabel to the center of the frame
	contentPane.add(moviePictureLabel);
	
    }
    
    private void setUpLabels() {
	movieLabel = new JLabel("Movie : Titanic");
	Color foregroundColor = Color.red;
	Color backgroundColor = Color.blue;
	movieLabel.setOpaque(true); // set the label opaque means 
	                            // the label  ignores the
				    // background for the parent container. 
				     // that make it more 
				    // efficent to draw
	movieLabel.setForeground(foregroundColor); // set the color of the text
	movieLabel.setBackground(backgroundColor); // setbackground color
	
	directorLabel = new JLabel("Director : James Cameron");
	directorLabel.setOpaque(true);
	directorLabel.setForeground(foregroundColor); // set the color of the text
	directorLabel.setBackground(backgroundColor); // setbackground color
	
	actorLabel = new JLabel("Actor :  Leonardo DiCaprio");
	actorLabel.setOpaque(true);
	actorLabel.setForeground(foregroundColor); // set the color of the text
	actorLabel.setBackground(backgroundColor); // setbackground color
	
	actressLabel = new JLabel("Actress : Kate Winslet");
	actressLabel.setOpaque(true);
	actressLabel.setForeground(foregroundColor); // set the color of the text
	actressLabel.setBackground(backgroundColor); // setbackground color
	
	moviePictureLabel = new JLabel(new ImageIcon("titanic.jpg"));
	moviePictureLabel.setOpaque(true);
	moviePictureLabel.setBackground(backgroundColor); // setbackground color
    }
	
    public static void main(String[] args) {
        Titanic t = new Titanic();
        t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	t.pack();
	t.setVisible(true);
    }	
	
}  
    
