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.

OpenController.java 1.2KB

3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 controller;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.event.ActionListener;
  9. import java.io.File;
  10. import java.util.Locale;
  11. import javax.swing.JFileChooser;
  12. import view.MainWindow;
  13. /**
  14. *
  15. * @author PC
  16. */
  17. public class OpenController implements ActionListener{
  18. private MainWindow mainwindow;
  19. public OpenController(MainWindow mainwindow)
  20. {
  21. this.mainwindow = mainwindow;
  22. registerEvents();
  23. }
  24. public void registerEvents()
  25. {
  26. mainwindow.getJbOpen().addActionListener(this);
  27. mainwindow.getFileOpen().addActionListener(this);
  28. }
  29. @Override
  30. public void actionPerformed(ActionEvent ae) {
  31. int wahl = mainwindow.getjFileChooser().showOpenDialog(mainwindow);
  32. if(wahl == JFileChooser.APPROVE_OPTION)
  33. {
  34. File file = mainwindow.getjFileChooser().getSelectedFile();
  35. mainwindow.getStatusbar().setText(file.getAbsolutePath());
  36. }
  37. }
  38. }