List of usage examples for javax.swing JFileChooser setCurrentDirectory
@BeanProperty(preferred = true, description = "The directory that the JFileChooser is showing files of.") public void setCurrentDirectory(File dir)
From source file:com.peterbochs.PeterBochsDebugger.java
private void jOpenELFButtonActionPerformed(ActionEvent evt) { JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(Setting.getInstance().getLastElfHistoryOpenDir())); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { openELF(fc.getSelectedFile());/*from ww w .j av a 2s .co m*/ parseELF(fc.getSelectedFile()); } }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jOpenELFDumpButtonActionPerformed(ActionEvent evt) { JFileChooser fc = new JFileChooser(); // load history fc.setCurrentDirectory(new File(Setting.getInstance().getLastElfHistoryOpenDir2())); // end load history int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); jELFComboBox.addItem(file);/* ww w . ja v a 2 s .c o m*/ parseELF(file); openELF(file); // save history Setting.getInstance().setLastElfHistoryOpenDir2(file.getParentFile().getAbsolutePath()); Setting.getInstance().save(); // end save history } }
From source file:net.technicpack.launcher.ui.LauncherFrame.java
protected void launchModpack() { ModpackModel pack = modpackSelector.getSelectedPack(); boolean requiresInstall = false; if (pack == null || (pack.getInstalledPack() == null && (pack.getPackInfo() == null || !pack.getPackInfo().isComplete()))) return;// w w w . java2s.co m if (pack.getInstalledDirectory() == null) { requiresInstall = true; pack.save(); modpackSelector.forceRefresh(); } if (requiresInstall) { try { if (pack.getPackInfo().shouldForceDirectory() && FilenameUtils.directoryContains(directories.getLauncherDirectory().getCanonicalPath(), pack.getInstalledDirectory().getCanonicalPath())) { JFileChooser chooser = new JFileChooser(directories.getLauncherDirectory()); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setCurrentDirectory(directories.getLauncherDirectory()); int result = chooser.showOpenDialog(this); if (result == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); if (file.list().length > 0) { JOptionPane.showMessageDialog(this, resources.getString("modpackoptions.move.errortext"), resources.getString("modpackoptions.move.errortitle"), JOptionPane.WARNING_MESSAGE); return; } else if (FileUtils.directoryContains(directories.getLauncherDirectory(), file)) { JOptionPane.showMessageDialog(this, resources.getString("launcher.launch.requiresmove"), resources.getString("launcher.launch.requiretitle"), JOptionPane.WARNING_MESSAGE); return; } pack.setInstalledDirectory(file); } } } catch (IOException ex) { Utils.getLogger().log(Level.SEVERE, ex.getMessage(), ex); } } boolean forceInstall = false; Version installedVersion = pack.getInstalledVersion(); //Force a full install (check cache, redownload, unzip files) if we have no current installation of this modpack if (installedVersion == null) forceInstall = true; else if (pack.getBuild() != null && !pack.isLocalOnly()) { //Ask the user if they want to update to the newer version if: //1- the pack build is RECOMMENDED & the recommended version is diff from the installed version //2- the pack build is LATEST & the latest version is diff from the installed version //3- the pack build is neither LATEST or RECOMMENDED & the pack build is diff from the installed version boolean requestInstall = false; if (pack.getBuild().equalsIgnoreCase(InstalledPack.RECOMMENDED) && pack.getPackInfo().getRecommended() != null && !pack.getPackInfo().getRecommended().equalsIgnoreCase(installedVersion.getVersion())) requestInstall = true; else if (pack.getBuild().equalsIgnoreCase(InstalledPack.LATEST) && pack.getPackInfo().getLatest() != null && !pack.getPackInfo().getLatest().equalsIgnoreCase(installedVersion.getVersion())) requestInstall = true; else if (!pack.getBuild().equalsIgnoreCase(InstalledPack.RECOMMENDED) && !pack.getBuild().equalsIgnoreCase(InstalledPack.LATEST) && !pack.getBuild().equalsIgnoreCase(installedVersion.getVersion())) requestInstall = true; //If the user says yes, update, then force a full install if (requestInstall) { int result = JOptionPane.showConfirmDialog(this, resources.getString("launcher.install.query"), resources.getString("launcher.install.query.title"), JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); if (result == JOptionPane.YES_OPTION) { forceInstall = true; } } } //If we're forcing an install, then derive the installation build from the pack build //otherwise, just use the installed version String installBuild = null; if (forceInstall && !pack.isLocalOnly()) { installBuild = pack.getBuild(); if (installBuild.equalsIgnoreCase(InstalledPack.RECOMMENDED)) installBuild = pack.getPackInfo().getRecommended(); else if (installBuild.equalsIgnoreCase(InstalledPack.LATEST)) installBuild = pack.getPackInfo().getLatest(); } else installBuild = installedVersion.getVersion(); if (requiresInstall) { installer.justInstall(resources, pack, installBuild, forceInstall, this, installProgress); } else { installer.installAndRun(resources, pack, installBuild, forceInstall, this, installProgress); } installProgress.setVisible(true); installProgressPlaceholder.setVisible(false); userChanged(userModel.getCurrentUser()); invalidate(); }
From source file:nick.gaImageRecognitionGui.panel.JPanelTestSavedConfiguration.java
private void jButtonSelectImagesFolderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSelectImagesFolderActionPerformed JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new java.io.File(".")); fc.setDialogTitle(StringConstants.SELECT_TEST_IMAGES_FOLDER); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setAcceptAllFileFilterUsed(false); if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { String path = fc.getSelectedFile().getPath(); RuntimeConfiguration.getInstance().setTestImagesFolderLocation(path); testImagesFolderLocation.setText(path); } else {/*from w w w .j av a2s . c o m*/ String path = RuntimeConfiguration.getInstance().getTestImagesFolderLocation(); if (StringUtils.isNotBlank(path)) { testImagesFolderLocation.setText(path); } } }
From source file:nick.gaImageRecognitionGui.panel.JPanelTestSavedConfiguration.java
private void jButtonSelectConfigurationFolderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSelectConfigurationFolderActionPerformed JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new java.io.File(".")); fc.setDialogTitle(StringConstants.SELECT_TEST_IMAGES_FOLDER); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setAcceptAllFileFilterUsed(false); if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { String path = fc.getSelectedFile().getPath(); RuntimeConfiguration.getInstance().setTestConfigurationsFolderLocation(path); configurationsFolderLocation.setText(path); } else {//from w ww. ja v a2 s. c o m String path = RuntimeConfiguration.getInstance().getTestConfigurationsFolderLocation(); if (StringUtils.isNotBlank(path)) { configurationsFolderLocation.setText(path); } } }
From source file:nick.gaImageRecognitionGui.panel.JPanelTestSavedConfiguration.java
private void jButtonSelectFalseImagesFolder1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSelectFalseImagesFolder1ActionPerformed JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new java.io.File(".")); fc.setDialogTitle(StringConstants.SELECT_TEST_IMAGES_FOLDER); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setAcceptAllFileFilterUsed(false); if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { String path = fc.getSelectedFile().getPath(); RuntimeConfiguration.getInstance().setTestFalseImagesFolderLocation(path); testFalseImagesFolderLocation.setText(path); } else {//from w ww . j a v a2s. c om String path = RuntimeConfiguration.getInstance().getTestFalseImagesFolderLocation(); if (StringUtils.isNotBlank(path)) { testFalseImagesFolderLocation.setText(path); } } }
From source file:nick.gaImageRecognitionGui.panel.JPanelTraining.java
private void jButtonSelectTrainingFolderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSelectTrainingFolderActionPerformed JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new java.io.File(".")); fc.setDialogTitle(StringConstants.SELECT_TRAINING_FOLDER); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setAcceptAllFileFilterUsed(false); if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { String path = fc.getSelectedFile().getPath(); RuntimeConfiguration.getInstance().setTrainingFolderPath(path); trainingFolderLocation.setText(path); } else {//from www.j a va2 s . c om String path = RuntimeConfiguration.getInstance().getTrainingFolderPath(); if (StringUtils.isNotBlank(path)) { trainingFolderLocation.setText(path); } } }
From source file:nick.gaImageRecognitionGui.panel.JPanelTraining.java
private void jButtonSelectFalseImagesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSelectFalseImagesActionPerformed JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new java.io.File(".")); fc.setDialogTitle(StringConstants.SELECT_TRAINING_FOLDER); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setAcceptAllFileFilterUsed(false); if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { String path = fc.getSelectedFile().getPath(); RuntimeConfiguration.getInstance().setTrainingFalseImagesFolderPath(path); falseImagesFolderLoc.setText(path); } else {/* w ww . j a v a2 s .com*/ String path = RuntimeConfiguration.getInstance().getTrainingFalseImagesFolderPath(); if (StringUtils.isNotBlank(path)) { falseImagesFolderLoc.setText(path); } } }
From source file:nl.detoren.ijsco.ui.Mainscreen.java
private void addMenubar() { // Menu bar met 1 niveau Mainscreen ms = this; JMenuBar menubar = new JMenuBar(); JMenu filemenu = new JMenu("Bestand"); // File menu//from w ww . j av a 2 s . c om JMenuItem item; /* item = new JMenuItem("Openen..."); item.setAccelerator(KeyStroke.getKeyStroke('O', Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask())); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { // Create a file chooser final JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(System.getProperty("user.dir"))); // In response to a button click: int returnVal = fc.showOpenDialog(ms); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); logger.log(Level.INFO, "Opening: " + file.getAbsolutePath() + "."); //controller.leesBestand(file.getAbsolutePath()); ms.repaint(); } } }); filemenu.add(item); */ /* item = new JMenuItem("Opslaan"); item.setAccelerator(KeyStroke.getKeyStroke('S', Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask())); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { //controller.saveState(true, "save"); } }); filemenu.add(item); */ filemenu.addSeparator(); item = new JMenuItem("Instellingen..."); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { actieInstellingen(); } }); item.setAccelerator(KeyStroke.getKeyStroke('I', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); filemenu.add(item); filemenu.addSeparator(); item = new JMenuItem("Afsluiten"); item.setAccelerator(KeyStroke.getKeyStroke('Q', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { controller.saveState(false, null); System.exit(EXIT_ON_CLOSE); } }); filemenu.add(item); menubar.add(filemenu); /** * Toernooi menu */ JMenu toernooimenu = new JMenu("Toernooi"); item = new JMenuItem("Toernooiinformatie"); item.setAccelerator(KeyStroke.getKeyStroke('T', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //actieNieuweSpeler(null, null); bewerkToernooi(); hoofdPanel.repaint(); } }); toernooimenu.add(item); menubar.add(toernooimenu); /** * Spelersdatabase menu */ JMenu spelermenu = new JMenu("Spelersdatabase"); item = new JMenuItem("OSBO JSON lijst ophalen (Online)"); item.setAccelerator(KeyStroke.getKeyStroke('J', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //actieNieuweSpeler(null, null); leeslijstOnline("www.osbo.nl", "/jeugd/currentratings.json"); hoofdPanel.repaint(); } }); spelermenu.add(item); item = new JMenuItem("OSBO htmllijst ophalen !verouderd! (Online)"); item.setAccelerator(KeyStroke.getKeyStroke('O', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //actieNieuweSpeler(null, null); leeslijstOnline("www.osbo.nl", "/jeugd/jrating.htm"); hoofdPanel.repaint(); } }); spelermenu.add(item); item = new JMenuItem("OSBO/IJSCO compatible lijst inlezen (Bestand)"); item.setAccelerator(KeyStroke.getKeyStroke('L', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // Create a file chooser final JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(System.getProperty("user.dir"))); // In response to a button click: int returnVal = fc.showOpenDialog(ms); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); logger.log(Level.INFO, "Opening: " + file.getAbsolutePath() + "."); leesOSBOlijstBestand(file.getAbsolutePath()); } hoofdPanel.repaint(); } }); spelermenu.add(item); /* item = new JMenuItem("Groslijst CSV inlezen (Bestand) N/A"); item.setAccelerator(KeyStroke.getKeyStroke('C', Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask())); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //actieNieuweSpeler(null, null); // Create a file chooser final JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(System.getProperty("user.dir"))); // In response to a button click: int returnVal = fc.showOpenDialog(ms); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); logger.log(Level.INFO, "Opening: " + file.getAbsolutePath() + "."); leesCSV(file.getAbsolutePath()); } hoofdPanel.repaint(); } }); spelermenu.add(item); */ menubar.add(spelermenu); JMenu deelnemersmenu = new JMenu("Deelnemers"); item = new JMenuItem("Wis Deelnemerslijst"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // Create a file chooser wisDeelnemers(); hoofdPanel.repaint(); } }); deelnemersmenu.add(item); item = new JMenuItem("Importeren Deelnemerslijst"); item.setAccelerator(KeyStroke.getKeyStroke('I', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // Create a file chooser final JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(System.getProperty("user.dir"))); // In response to a button click: int returnVal = fc.showOpenDialog(ms); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); logger.log(Level.INFO, "Opening: " + file.getAbsolutePath() + "."); leesDeelnemers(file.getAbsolutePath()); } hoofdPanel.repaint(); } }); deelnemersmenu.add(item); item = new JMenuItem("Export Deelnemerslijst (JSON)"); item.setAccelerator(KeyStroke.getKeyStroke('E', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // Create a file chooser final JFileChooser fc = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("JSON", "json"); fc.setFileFilter(filter); fc.setCurrentDirectory(new File(System.getProperty("user.dir"))); // In response to a button click: int returnVal = fc.showSaveDialog(ms); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); logger.log(Level.INFO, "Opening: " + file.getAbsolutePath() + "."); schrijfDeelnemers(file.getAbsolutePath()); } hoofdPanel.repaint(); } }); deelnemersmenu.add(item); menubar.add(deelnemersmenu); JMenu uitslagenmenu = new JMenu("Uitslagen"); Component hs = this; item = new JMenuItem("Importeer uitslagenbestand"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // Create a file chooser final JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(System.getProperty("user.dir"))); // In response to a button click: int returnVal = fc.showOpenDialog(hs); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); logger.log(Level.INFO, "Opening: " + file.getAbsolutePath() + "."); status.groepenuitslagen = (GroepsUitslagen) new ExcelImport().importeerUitslagen(file); OutputUitslagen ou = new OutputUitslagen(); ou.exportuitslagen(status.groepenuitslagen); IJSCOController.t().wisUitslagen(); ou.exportJSON(status.groepenuitslagen); GroepsUitslagen verwerkteUitslag = new Uitslagverwerker() .verwerkUitslag(status.groepenuitslagen); logger.log(Level.INFO, verwerkteUitslag.ToString()); new OutputUitslagen().exporteindresultaten(verwerkteUitslag); JOptionPane.showMessageDialog(null, "Uitslagen geimporteerd en bestanden aangemaakt."); } hoofdPanel.repaint(); } }); uitslagenmenu.add(item); menubar.add(uitslagenmenu); JMenu osbomenu = new JMenu("OSBO"); item = new JMenuItem("Verstuur uitslagen handmatig."); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // Create a file chooser SendAttachmentInEmail SAIM = new SendAttachmentInEmail(); SAIM.sendAttachement("Uitslagen.json"); hoofdPanel.repaint(); } }); osbomenu.add(item); menubar.add(osbomenu); JMenu helpmenu = new JMenu("Help"); item = new JMenuItem("Verstuur logging"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // Create a file chooser SendAttachmentInEmail SAIM = new SendAttachmentInEmail(); SAIM.sendAttachement("IJSCO_UI.log"); hoofdPanel.repaint(); } }); helpmenu.add(item); item = new JMenuItem("About"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { AboutDialog ad = new AboutDialog(ms); ad.setVisible(true); hoofdPanel.repaint(); } }); helpmenu.add(item); menubar.add(helpmenu); /* JMenu indelingMenu = new JMenu("Indeling"); //item = new JMenuItem("Automatisch aan/uit"); item = new JMenuItem("N/A"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { //actieAutomatisch(); } }); indelingMenu.add(item); //item = new JMenuItem("Maak wedstrijdgroep"); item = new JMenuItem("N/A"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //actieMaakWedstrijdgroep(); } }); indelingMenu.add(item); //item = new JMenuItem("Maak speelschema"); item = new JMenuItem("N/A"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evetn) { //actieMaakSpeelschema(); } }); indelingMenu.add(item); //item = new JMenuItem("Bewerk speelschema"); item = new JMenuItem("N/A"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { //updateAutomatisch(false); // ResultaatDialoog //actieBewerkSchema(); } }); indelingMenu.add(item); indelingMenu.addSeparator(); //item = new JMenuItem("Export"); item = new JMenuItem("N/A"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { //actieExport(); } }); indelingMenu.add(item); indelingMenu.addSeparator(); //item = new JMenuItem("Vul uitslagen in"); item = new JMenuItem("N/A"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //actieVoerUitslagenIn(); } }); indelingMenu.add(item); //item = new JMenuItem("Externe spelers"); item = new JMenuItem("N/A"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //actieExterneSpelers(); } }); indelingMenu.add(item); //item = new JMenuItem("Maak nieuwe stand"); item = new JMenuItem("N/A"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //actieUpdateStand(); } }); indelingMenu.add(item); indelingMenu.addSeparator(); //item = new JMenuItem("Volgende ronde"); item = new JMenuItem("N/A"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //actieVolgendeRonde(); } }); indelingMenu.add(item); menubar.add(indelingMenu); */ /* JMenu overigmenu = new JMenu("Overig"); //item = new JMenuItem("Reset punten"); item = new JMenuItem("N/A"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //controller.resetPunten(); hoofdPanel.repaint(); } }); overigmenu.add(item); menubar.add(overigmenu); */ this.setJMenuBar(menubar); }
From source file:nl.fontys.sofa.limo.view.project.actions.ExportChainAction.java
private void openFileChooser() throws HeadlessException, IOException { JFileChooser fc = new ChainSaveFileChooser(); FileNameExtensionFilter chainFilter = new FileNameExtensionFilter("Supply chains (*.lsc)", "lsc"); if (supplyChain.getFilepath() != null) { //This happens if a supply chain is loaded. fc.setCurrentDirectory(new File(supplyChain.getFilepath())); }// w w w . j a va2 s. c o m fc.setFileFilter(chainFilter); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setSelectedFile(new File(FilenameUtils.removeExtension(supplyChain.getName()))); // This sets the name without the extension int result = fc.showOpenDialog(null); String fileName = fc.getSelectedFile().getName(); //name with extension if (result == JFileChooser.APPROVE_OPTION) { //If folder is selected than save the supply chain. supplyChain.setName(fileName); File file = fc.getSelectedFile(); supplyChain.saveToFile(file.getAbsolutePath() + ".lsc"); } else { //If no folder is selected throw an exception so the saving process is cancelled. throw new IOException("The supply chain " + supplyChain.getName() + " is invalid."); } }