Hvorfor virker min fileChooser ikke?
Den udskriver 'Jabbajabbahey', men åbner aldrig en filechooser!Nogen idéer til hvad der kan være galt?
...
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JFileChooser;
import java.io.File;
public class Controller
{
...
ActionListener browseAction;
public Controller(JFrame jf)
{
frame = jf;
...
browseAction = new ActionListener()
{
public void actionPerformed(ActionEvent e) {
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
System.out.println("jabbajabbahey");
if (e.getSource() == browseAction) {
int returnVal = fc.showOpenDialog(fc);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
file.getName();
}
}
}
};
myMainMenuView.setBrowseActionListener(this.browseAction);
....
}
}