You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CommandOpen.java 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package kontakte.controller;
  7. import java.io.FileOutputStream;
  8. import java.io.ObjectOutputStream;
  9. import javax.swing.JOptionPane;
  10. import kontakte.model.Model;
  11. import kontakte.view.View;
  12. /**
  13. *
  14. * @author nobody
  15. */
  16. public class CommandOpen implements CommandInterface
  17. {
  18. private View view;
  19. private Model model;
  20. public CommandOpen(View view, Model model)
  21. {
  22. this.view = view;
  23. this.model = model;
  24. }
  25. @Override
  26. public void execute()
  27. {
  28. try
  29. {
  30. view.getFileChooser().showOpenDialog(view);
  31. String fileAdd = view.getFileChooser().getSelectedFile().getAbsolutePath();
  32. view.getTextFileAdress().setText(fileAdd);
  33. }
  34. catch(Exception e)
  35. {
  36. JOptionPane.showMessageDialog(view, "Keine Datei ausgewählt.", "Fehler", JOptionPane.ERROR_MESSAGE);
  37. }
  38. }
  39. @Override
  40. public void undo()
  41. {
  42. }
  43. }