il metodo sortList ha già un parametro File.
ma quello che nn capisco è che devo fare qua:
codice:
public JFCSelect() throws FileNotFoundException {
super("Test JFileChooser");
File directory = new File();
StringBuilder lista = ListDir.sortList(directory);
dim = getToolkit().getScreenSize();
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setSize(400, 350);
setLocation(dim.width / 2 - this.getWidth() / 2, dim.height / 2 - this.getHeight() / 2);
setLayout(new FlowLayout());
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("File");
JMenuItem apriMenuItem = new JMenuItem("Seleziona directory");
JTextArea txtarea = new JTextArea();
txtarea.setPreferredSize(new Dimension(380, 280));
txtarea.setEditable(false);
txtarea.setText(lista.toString());
JScrollPane scrollPanel = new JScrollPane(txtarea);
scrollPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
menu.add(apriMenuItem);
menuBar.add(menu);
setJMenuBar(menuBar);
add(txtarea);
add(scrollPanel);
apriMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
operazioneApri();
}
});
}
private void operazioneApri() {
if (fc == null) {
fc = new JFileChooser();
}
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int stato = fc.showOpenDialog(this);
if (stato == JFileChooser.APPROVE_OPTION) {
File dir = fc.getSelectedFile();
}
}
ListDir è la classe dove listo i file e directory.
al File directory devo passare la scelta fatta in operazioneApri.