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.

C_FileDialogOpen.java 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* ALT
  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.prefs.Preferences;
  11. import javax.swing.JFileChooser;
  12. import view.gui;
  13. /**
  14. *
  15. * @author endresma66479
  16. *
  17. public class C_FileDialogOpen implements ActionListener
  18. {
  19. gui frm;
  20. File data;
  21. String PATH_ID;
  22. Preferences pref;
  23. public C_FileDialogOpen(gui g, String ID, Preferences p)
  24. {
  25. this.frm = g;
  26. this.data = null;
  27. this.PATH_ID = ID;
  28. this.pref = p;
  29. }
  30. public void registerEvents()
  31. {
  32. this.frm.getBtnOpen().addActionListener(this);
  33. this.frm.getMiOpen().addActionListener(this);
  34. this.frm.getMiOpen_popup().addActionListener(this);
  35. }
  36. @Override
  37. public void actionPerformed(ActionEvent ae)
  38. {
  39. System.out.println("opening a file...");
  40. System.out.println(this.pref.get(PATH_ID, "xyz"));
  41. JFileChooser fc = this.frm.getFileChooser();
  42. if(fc.showOpenDialog(frm) == JFileChooser.APPROVE_OPTION)
  43. {
  44. this.data = fc.getSelectedFile();
  45. this.frm.getLblFilePath().setText(this.data.getAbsolutePath());
  46. this.pref.put(this.PATH_ID, this.data.getAbsolutePath());
  47. System.out.println(this.pref.get(PATH_ID, "xyz"));
  48. }
  49. }
  50. }
  51. */