
import javax.swing.JApplet;
import javax.swing.*;

import java.io.*;
import java.awt.event.*;


public class Resim4 extends JApplet  {

  private JMenuBar menuBar1;   // MenüContainer
  private JMenu mainFile;      // Hauptmenü
  private JMenuItem mnNew;     // Menüeintrag
  private JMenuItem mnOpen;   
  private JMenuItem mnSaveAs;
  private JMenuItem mnClose;   
  private JTextArea editor;

    //Called when this applet is loaded into the browser.
    public void init() {
        //this.getContentPane().setLayout( new BorderLayout() );
        editor = new JTextArea();
        add( editor );
        setMenus();
    }

  private void setMenus() {
    menuBar1 = new JMenuBar();

      // DATEI
    mainFile = new JMenu("Datei");
    mnNew = new JMenuItem("Neu");
    mnOpen = new JMenuItem("ÖÖffnen");
    mnSaveAs = new JMenuItem("Speichern unter");
    mnClose = new JMenuItem("Schließen");

    mainFile.add(mnNew);
    mainFile.add(mnOpen);
    mainFile.addSeparator();
    mainFile.add(mnSaveAs);
    mainFile.add(mnClose);

   mnOpen.addActionListener(new java.awt.event.ActionListener() {
       public void actionPerformed(ActionEvent e) {
        mnOpen_Click();
     }
    });

    mainFile.add(mnClose);
    menuBar1.add(mainFile);
    this.setJMenuBar(menuBar1);
  } // setMenus

  void mnOpen_Click() {
    editor.setText("mnOpen_Click1");
   editor.updateUI();
    JFileChooser fc = new JFileChooser();
    editor.setText("mnOpen_Click2");
   editor.updateUI();
     int returnVal = fc.showOpenDialog(null);
    editor.setText("mnOpen_Click3");
   editor.updateUI();
/*
    editor.setText("mnOpen_Click1");
   JFileChooser jFileChooser1 = new JFileChooser();
    editor.setText("mnOpen_Click2");
   editor.updateUI();
   String sFileName;

    editor.setText("mnOpen_Click3");
    editor.updateUI();

//   jFileChooser1.setMultiSelectionEnabled(false);
    editor.setText("mnOpen_Click4");
   editor.updateUI();
//   jFileChooser1.setCurrentDirectory(  new File(  (String) System.getProperties().get("user.dir")  )   );
    editor.setText("mnOpen_Click5");
   editor.updateUI();

      // Aufruf des Dialogfensters
    if (JFileChooser.APPROVE_OPTION == jFileChooser1.showOpenDialog(this)) {
        // holen des Dateinamens
      sFileName = jFileChooser1.getSelectedFile().getPath();
      readResimFile(sFileName);
    }
*/
  }  // mnOpen

  private void readResimFile(String filename) {
    FileInputStream fin;
    InputStreamReader iin;
    LineNumberReader din;
    String sLine;
    String sText="";
    try {
      fin = new FileInputStream(filename);
      iin = new InputStreamReader(fin);
      din = new LineNumberReader(iin);
      while  ( din.ready() ) {
        sLine = din.readLine();
        sText+=sLine;
      }
      editor.setText(sText);
    }
    catch (IOException ee) {
           System.err.println("IOException: " + ee);
    }
  }


    public void destroy() {
    	
    }
    public void start() {
    	
    }
    public void paint() {
    	
    }
    public void stop() {
    	
    }
    

}
