
// ImageViewer.java
// Michael Kolling and David J Barnes 
// version 0.2
// Modified by Andrew Davison, Jan 2018, ad@fivedots.coe.psu.ac.th

/* ImageViewer is the main class of the image viewer application. It builds
   and displays the application GUI and initialises all other components. 

   This version displays a menu bar and label, but doesn't have a listener
   for the menu items.
 */


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


public class ImageViewer extends JFrame
{
    
  public ImageViewer()
  {
    super("ImageViewer 0.2");

    // create the GUI
    makeMenuBar();

    Container c = getContentPane();
    JLabel label = new JLabel("I am a label. I can display some text.");
    c.add(label);

    // set close behaviour for JFrame as exit
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    pack(); // reduce frame size to fit GUI component
    setVisible(true);
  }  // end of ImageViewer()


  private void makeMenuBar()
  // Create the main frame's menu bar.
  {
    JMenuBar menubar = new JMenuBar();
    setJMenuBar(menubar);
        
    // create the File menu
    JMenu fileMenu = new JMenu("File");
    menubar.add(fileMenu);
        
    JMenuItem openItem = new JMenuItem("Open");
    fileMenu.add(openItem);

    JMenuItem quitItem = new JMenuItem("Quit");
    fileMenu.add(quitItem);
  }  // end of makeMenuBar()


  // ----------------------------------------------

  public static void main(String[] args) 
  {  new ImageViewer(); } 

} // end of ImageViewer class
