package main;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFileChooser;

class CSVFileLoadListener implements ActionListener {
    StartApplet applet;
    
    public CSVFileLoadListener(StartApplet applet) {
        this.applet = applet;
    }

    public void actionPerformed(ActionEvent e) {
        JFileChooser fc = new JFileChooser();
        int choice = fc.showOpenDialog(fc);
        if ( choice == JFileChooser.APPROVE_OPTION ) {
            applet.title_Label.setBounds(10, 150, 120, 20);
            applet.title_Label.setVisible(true);
            applet.title_yes_Button.setBounds(125, 150, 50, 20);
            applet.title_yes_Button.setVisible(true);
            applet.title_no_Button.setBounds(175, 150, 50, 20);
            applet.title_no_Button.setVisible(true);
            applet.read_Label.setBounds(10, 180, 120, 20);
            applet.read_Label.setVisible(true);
            applet.read_top_Button.setSelected(true);
            applet.read_top_Button.setBounds(125, 180, 125, 20);
            applet.read_top_Button.setVisible(true);
            applet.read_bottom_Button.setBounds(250, 180, 130, 20);
            applet.read_bottom_Button.setVisible(true);
            applet.column_Label.setBounds(10, 210, 280, 20);
            applet.column_Label.setVisible(true);
            applet.column_Field.setValue(1);
            applet.column_Field.setBounds(290, 210, 40, 20);
            applet.column_Field.setVisible(true);

            //nuskaitom CSV failą
            applet.filepath = fc.getSelectedFile().getPath();
            applet.CSVTable();
        }
    }
}