/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package adressmanagement.controller; import adressmanagement.model.AdressmanagementModel; import adressmanagement.view.AdressmanagementView; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JFileChooser; /** * * @author chris */ public class ControllerOpen implements ActionListener { private AdressmanagementView view; private AdressmanagementModel model; public ControllerOpen() { } public ControllerOpen(AdressmanagementView view, AdressmanagementModel model) { // lasteSelected = Preferences this.view = view; this.model = model; } public void registerEvents() { view.getBtnOpen().addActionListener(this); } @Override public void actionPerformed(ActionEvent e) { int choice = view.getFileChooser().showOpenDialog(view); if (choice == JFileChooser.APPROVE_OPTION) { File selectedFile = view.getFileChooser().getSelectedFile(); view.getLblStatus().setText("File +" + selectedFile.getAbsolutePath()); // try // { // model.readFromFile(selectedFile); // String text = model.getText(); // } // catch (UnsupportedEncodingException ex) // { // view.getLblStatus().setText(ex.toString()); // } // catch (IOException ex) // { // view.getLblStatus().setText(ex.toString()); // } } } }