//Titel:            SDI-Fenster
//Version:          1.0
//Copyright:
//Autor:
//Firma:
//Beschreibung:


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;  // Exception

// Opendialog
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.filechooser.*;
//import java.util.Hashtable;  // Filter
//import java.util.Enumeration; // Filter

// InternalFrame
import javax.swing.event.*;


public class s1 extends JFrame {
    // Menü Variablen
  private JMenuBar menuBar1;
  private JMenu MainFile;
  private JMenuItem MnNew;
  private JMenuItem MnOpen;
  private JMenuItem MnClose;

  private JMenu MainEdit;
  private JMenuItem MnCut;
  private JMenuItem MnCopy;
  private JMenuItem MnInsert;

  private JTree element = new JTree();

   // Konstruktor
  public s1() {
    setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    setGUI();
  }

  public void setGUI() {
    this.getContentPane().setLayout( new BorderLayout() );
    this.setSize(new Dimension(600, 400));
    this.setVisible(true);
    this.getContentPane().add(element, BorderLayout.CENTER);
    setMenus();
  }  // setGUI


    // setzt die Menüs
  private void setMenus() {
    menuBar1 = new JMenuBar();

      // DATEI
    MainFile = new JMenu("Datei");
    MnNew = new JMenuItem("Neu");
    MnOpen = new JMenuItem("Öffnen");
    MnClose = new JMenuItem("Schließen");

    MnNew.addActionListener(new ActionListener()  {
      public void actionPerformed(ActionEvent e) {
        MnNew_click();
      }
    });
    MnNew.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
    MainFile.add(MnNew);

    MnOpen.addActionListener(new ActionListener()  {
      public void actionPerformed(ActionEvent e) {
        MnOpen_click();
      }
    });
    MnOpen.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    MainFile.add(MnOpen);
    MainFile.addSeparator();

    // --------------------------
    MnClose.addActionListener(new ActionListener()  {

      public void actionPerformed(ActionEvent e) {
        MnClose_click();
      }
    });
    MainFile.add(MnClose);

    menuBar1.add(MainFile);

    // EDIT
    MainEdit = new JMenu("Bearbeiten");
    MnCut = new JMenuItem("Ausschneiden");
    MnCopy = new JMenuItem("Kopieren");
    MnInsert = new JMenuItem("Einfügen");

    MnCut.addActionListener(new ActionListener()  {
      public void actionPerformed(ActionEvent e) {
        MnCut_click();
      }
    });
    MainEdit.add(MnCut);

    MnCopy.addActionListener(new ActionListener()  {
      public void actionPerformed(ActionEvent e) {
        MnCopy_click();
      }
    });
    MainEdit.add(MnCopy);
    // MainFile.addSeparator();

    // --------------------------
    MnInsert.addActionListener(new ActionListener()  {
      public void actionPerformed(ActionEvent e) {
        MnInsert_click();
      }
    });
    MainEdit.add(MnInsert);
    menuBar1.add(MainEdit);

    this.setJMenuBar(menuBar1);
  } // setMenus


  void MnNew_click() {
	  System.out.println("Neue Datei");
  }

  void MnOpen_click() {
   JFileChooser jFileChooser1 = new JFileChooser();
   String sFileName;

   jFileChooser1.setMultiSelectionEnabled(false);
   jFileChooser1.setCurrentDirectory( new File("C:\\DATEN") );
   if (JFileChooser.APPROVE_OPTION == jFileChooser1.showOpenDialog(this)) {
		sFileName = jFileChooser1.getSelectedFile().getPath();
	  System.out.println("Neue Datei");
    }
  }  // MnOpen

  void MnClose_click() {
    System.exit(0);
  }

   // -----------------
  void MnCut_click() {
    System.out.println("Menüeintrag Cut");
  }
  void MnCopy_click() {
    System.out.println("Menüeintrag Copy");
  }
  void MnInsert_click() {
    System.out.println("Menüeintrag Insert");
  }



  static public void main(String[] args) {
    s1 frame = new s1();
    frame.setVisible(true);
  }

}  // s1
