日期:2014-05-20  浏览次数:20662 次

java 导入文件路径时记住以前的路径
项目是用swing做的,不是ssh框架,在导入文件时每次的路径都是My Document,希望能够记住之前选择的路径,不用每次都要选择。

这里的牛人们,给个建议吖,感激不尽!

------解决方案--------------------
探讨
没有接触过这个,能否详细一些?

引用:

存xml或者数据库 每次进这个页面直接访问放回即可

------解决方案--------------------
弄个变量每次执行的时候给它赋值。
再次打开的时候setselectFile就行了。
------解决方案--------------------
http://ootabc.iteye.com/blog/379854
------解决方案--------------------
Java code

jButton2.setText("Load");
        jButton2.addActionListener(new ActionListener() {
            JFileChooser chooser = new JFileChooser();
            public void actionPerformed(ActionEvent evt) {
                    int result = chooser.showOpenDialog(null);
                    if(result == JFileChooser.APPROVE_OPTION){
                        String pathname = chooser.getSelectedFile().getParentFile().getName();                        System.out.println("File Directory: "+pathname);
                    }
            }
        });

------解决方案--------------------
楼上说得有道,JFileChooser chooser 做成全局变量吧