yuxc
2025-01-15 c09f81131e8b7c83937206d7cf76f34d2020be75
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.vci.client.workflow.template;
 
import javax.swing.JFileChooser;
 
import com.vci.client.LogonApplication;
import com.vci.client.ui.swing.components.VCIJDialog;
 
/**
 * 导出模板文件
 * @author liudi
 *
 * 2013-8-7
 */
public class FileChooseDiaog  extends VCIJDialog {
 
    private JFileChooser fileChooser = new JFileChooser();
    private String filepath = "";
    private String fileName = "";
    private String flag = "";
    
    public JFileChooser getFileChooser() {
        return fileChooser;
    }
 
    public void setFileChooser(JFileChooser fileChooser) {
        this.fileChooser = fileChooser;
    }
 
    public String getFileName() {
        return fileName;
    }
 
    public void setFileName(String fileName) {
        this.fileName = fileName;
    }
 
    public String getFilepath() {
        return filepath;
    }
 
    public void setFilepath(String filepath) {
        this.filepath = filepath;
    }
 
    public FileChooseDiaog(String flag){
        super(LogonApplication.frame, true);
        this.flag = flag;
        init();
    }
    
    private void init(){
        this.getContentPane().add(fileChooser);
        if("export".equals(flag)){
            fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
            int result = fileChooser.showSaveDialog(this);  // 打开"打开文件"对话框
            if (result == JFileChooser.OPEN_DIALOG) {
                filepath = fileChooser.getCurrentDirectory().toString();
                fileName = fileChooser.getSelectedFile().getName();
                System.out.println("filepath = " + filepath+":fileName = "+fileName);
            }
        }else if("import".equals(flag)){
            int result = fileChooser.showOpenDialog(this);  // 打开"打开文件"对话框
            if (result == JFileChooser.OPEN_DIALOG) {
                filepath = fileChooser.getCurrentDirectory().toString();
                fileName = fileChooser.getSelectedFile().getName();
                System.out.println("filepath = " + filepath+":fileName = "+fileName);
            }
        }
        
    }
}