private AbstractAction getxxxabstractAction() {
if(xxxabstractAction == null) {
xxxabstractAction = new AbstractAction("Choose", null) {
public void actionPerformed(ActionEvent evt) {
getFileChooser1().setVisible(true);         
getFileChooser1().setLocation(null); 
}
};
}
return xxxabstractAction;
}
我是用esclipe的GUI..想经一个主介面的一个按键去开一个jfilechooser 但是不管怎样也出error

解决方案 »

  1.   

            browseButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    // 选择文件夹
                    final JFileChooser chooser = new JFileChooser();
                    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                    int result = chooser.showOpenDialog(PathTree.this);                if (result == JFileChooser.APPROVE_OPTION) {
                        Thread t = new Thread(new Runnable() {
                            @Override
                            public void run() {
                                File dir = chooser.getSelectedFile();
                                pathsTextArea.setText("");
                                stopped = false;
                                walkTree(dir, 0);
                            }
                        });
                        t.start();
                    }
                }
            });