Makes all folder selection use a common method

This commit is contained in:
Kristian Knarvik 2020-08-17 22:19:30 +02:00
parent a3de8a9f6c
commit cc0a5a1659

View File

@ -9,6 +9,7 @@ import javax.naming.ConfigurationException;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
/**
* Contains all buttons for configuring a server.
@ -207,13 +208,9 @@ public class ServerTab implements ActionListener {
* Sets the directory input's value if successful.
*/
private void browse() {
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new java.io.File("/"));
chooser.setDialogTitle("Server folder");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setAcceptAllFileFilterUsed(false);
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
directory.setText(chooser.getSelectedFile().toString());
File chosenFolder = Main.getController().getGUI().askForDirectory("Server folder");
if (chosenFolder != null) {
directory.setText(chosenFolder.toString());
}
}