Example usage for javax.swing JFileChooser APPROVE_OPTION

List of usage examples for javax.swing JFileChooser APPROVE_OPTION

Introduction

In this page you can find the example usage for javax.swing JFileChooser APPROVE_OPTION.

Prototype

int APPROVE_OPTION

To view the source code for javax.swing JFileChooser APPROVE_OPTION.

Click Source Link

Document

Return value if approve (yes, ok) is chosen.

Usage

From source file:io.heming.accountbook.ui.MainFrame.java

private void exportRecords() {
    final JFileChooser chooser = new JFileChooser();
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.addChoosableFileFilter(new AbbFileFilter());
    chooser.setAcceptAllFileFilterUsed(false);
    int value = chooser.showSaveDialog(this);
    if (value == JFileChooser.APPROVE_OPTION) {
        final File file = chooser.getSelectedFile();
        disableAllControls();/*w w w  .  jav  a2s .  co  m*/
        new Thread() {
            @Override
            public void run() {
                try {
                    statusLabel.setIcon(new ImageIcon(getClass().getResource("loader.gif")));
                    setStatusText("?...");
                    FacadeUtil.shutdown();
                    // .abb?
                    setStatusText("?...");
                    List<String> exclusion = Arrays.asList();
                    if (!file.getName().endsWith(".abb")) {
                        ZIPUtil.compress(new File(Constants.DATA_DIR),
                                new File(file.getAbsolutePath() + ".abb"), exclusion);
                    } else {
                        ZIPUtil.compress(new File(Constants.DATA_DIR), file, exclusion);
                    }
                    setStatusText("??...");
                    FacadeUtil.restart();
                    enableAllControls();
                    setStatusText("");
                    statusLabel.setIcon(new ImageIcon(getClass().getResource("stopped-loader.png")));
                    JOptionPane.showMessageDialog(MainFrame.this, String.format("?"), "?",
                            JOptionPane.INFORMATION_MESSAGE);
                } catch (IOException e) {
                    JOptionPane.showMessageDialog(MainFrame.this, String.format(""), "",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        }.start();
    }
}

From source file:dylemator.UserList.java

private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportButtonActionPerformed
    if (this.filenameCombo.getSelectedIndex() == 0)
        return;/* w  w  w .  ja v a  2 s. c  om*/
    String sheetName = (String) this.filenameCombo.getSelectedItem();
    Workbook wb = new XSSFWorkbook();
    Sheet sheet = wb.createSheet(sheetName);
    Row headerRow = sheet.createRow(0);
    String[] headers = exportData.get(0);
    int numOfColumns = headers.length;
    for (int i = 0; i < numOfColumns; i++) {
        Cell cell = headerRow.createCell(i);
        cell.setCellValue(headers[i]);
    }

    int rowCount = exportData.size();
    for (int rownum = 1; rownum < rowCount; rownum++) {
        Row row = sheet.createRow(rownum);
        String[] values = exportData.get(rownum);
        for (int i = 0; i < numOfColumns; i++) {
            Cell cell = row.createCell(i);
            cell.setCellValue(values[i]);
        }
    }

    String defaultFilename = "Export.xlsx";
    JFileChooser f = new JFileChooser(System.getProperty("user.dir"));
    f.setSelectedFile(new File(defaultFilename));
    f.setDialogTitle("Wybierz nazw dla pliku eksportu");
    f.setFileSelectionMode(JFileChooser.FILES_ONLY);
    FileFilter ff = new FileFilter() {
        @Override
        public boolean accept(File file) {
            if (file.getName().endsWith(".xlsx"))
                return true;
            return false;
        }

        @Override
        public String getDescription() {
            return "";
        }
    };
    f.setFileFilter(ff);

    File file = null;
    int save = f.showSaveDialog(this);
    if (save == JFileChooser.APPROVE_OPTION)
        file = f.getSelectedFile();
    else
        return;

    FileOutputStream out;
    try {
        out = new FileOutputStream(file);
        wb.write(out);
        out.close();
    } catch (FileNotFoundException ex) {
        Logger.getLogger(UserList.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(UserList.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:fll.scheduler.SchedulerUI.java

void saveScheduleDescription() {
    if (null == mScheduleDescriptionFile) {
        // prompt the user for a filename to save to

        final String startingDirectory = PREFS.get(DESCRIPTION_STARTING_DIRECTORY_PREF, null);

        final JFileChooser fileChooser = new JFileChooser();
        final FileFilter filter = new BasicFileFilter("FLL Schedule Description (properties)",
                new String[] { "properties" });
        fileChooser.setFileFilter(filter);
        if (null != startingDirectory) {
            fileChooser.setCurrentDirectory(new File(startingDirectory));
        }/*from  w w  w. j  a va2 s .c  o  m*/

        final int returnVal = fileChooser.showSaveDialog(SchedulerUI.this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            final File currentDirectory = fileChooser.getCurrentDirectory();
            PREFS.put(DESCRIPTION_STARTING_DIRECTORY_PREF, currentDirectory.getAbsolutePath());

            mScheduleDescriptionFile = fileChooser.getSelectedFile();
            mDescriptionFilename.setText(mScheduleDescriptionFile.getName());
        } else {
            // user canceled
            return;
        }
    }

    try (final Writer writer = new OutputStreamWriter(new FileOutputStream(mScheduleDescriptionFile),
            Utilities.DEFAULT_CHARSET)) {
        final SolverParams params = mScheduleDescriptionEditor.getParams();
        final List<String> errors = params.isValid();
        if (!errors.isEmpty()) {
            final String formattedErrors = errors.stream().collect(Collectors.joining("\n"));
            JOptionPane.showMessageDialog(SchedulerUI.this,
                    "There are errors that need to be corrected before the description can be saved: "
                            + formattedErrors,
                    "Error saving file", JOptionPane.ERROR_MESSAGE);
        } else {
            final Properties properties = new Properties();
            params.save(properties);
            properties.store(writer, null);
        }
    } catch (final IOException e) {
        final Formatter errorFormatter = new Formatter();
        errorFormatter.format("Error saving file: %s", e.getMessage());
        LOGGER.error(errorFormatter, e);
        JOptionPane.showMessageDialog(SchedulerUI.this, errorFormatter, "Error saving file",
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:org.spf4j.ui.TSDBViewJInternalFrame.java

@edu.umd.cs.findbugs.annotations.SuppressWarnings("UP_UNUSED_PARAMETER")
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    TreePath[] selectionPaths = measurementTree.getSelectionPaths();
    List<String> selectedTables = getSelectedTables(selectionPaths);
    if (!selectedTables.isEmpty()) {
        JFileChooser chooser = new JFileChooser();
        chooser.setDialogType(JFileChooser.SAVE_DIALOG);
        int returnVal = chooser.showOpenDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = chooser.getSelectedFile();
            try {
                tsDb.writeCsvTables(selectedTables, file);
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            }//from w  w  w  . ja  v  a 2 s  . c  o  m
        }
    }
}

From source file:com.igormaznitsa.jhexed.swing.editor.ui.dialogs.hexeditors.DialogEditSVGImageValue.java

private void buttonLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonLoadActionPerformed
    final JFileChooser openDialog = new JFileChooser(lastOpenedFile);
    openDialog.setDialogTitle("Select SVG file");
    openDialog.setAcceptAllFileFilterUsed(true);
    openDialog.setFileFilter(Utils.SVG_FILE_FILTER);

    if (openDialog.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        lastOpenedFile = openDialog.getSelectedFile();
        try {/* w ww .  j  av a 2 s.c o  m*/
            final SVGImage img = new SVGImage(lastOpenedFile);

            this.value.setImage(img);

            this.panelPreview.removeAll();
            this.panelPreview.add(
                    new JLabel(new ImageIcon(
                            img.rasterize(PREVIEW_SIZE, PREVIEW_SIZE, BufferedImage.TYPE_INT_ARGB))),
                    BorderLayout.CENTER);
            this.panelPreview.revalidate();
            this.panelPreview.repaint();

            this.buttonOk.setEnabled(true);
            this.buttonSaveAs.setEnabled(true);
        } catch (IOException ex) {
            Log.error("Can't rasterize image [" + lastOpenedFile + ']', ex);
            JOptionPane.showMessageDialog(this, "Can't load the file, may be it is not a SVG file",
                    "Can't load the file", JOptionPane.ERROR_MESSAGE);
        }
    }
}

From source file:MyFormApp.java

private void AddbuttonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_AddbuttonMouseClicked
    // TODO add your handling code here:
    //? ?// ww w. j  a  v a 2  s. c o  m
    JFileChooser fileChooser = new JFileChooser(); //?
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("PDF Documents", "pdf"));//?pdf
    fileChooser.setAcceptAllFileFilterUsed(false);
    int returnValue = fileChooser.showOpenDialog(null);
    if (returnValue == JFileChooser.APPROVE_OPTION) {//????
        File selectedFile = fileChooser.getSelectedFile();
        try {
            pdfToimage(selectedFile); //???
        } catch (IOException ex) {
            Logger.getLogger(MyFormApp.class.getName()).log(Level.SEVERE, null, ex);
        }

        System.out.println(selectedFile.getName()); //??
        File source = new File("" + selectedFile);
        File dest = new File(PATH + selectedFile.getName());
        //copy file conventional way using Stream
        long start = System.nanoTime();
        //copy files using apache commons io
        start = System.nanoTime();
        int a = i + 1;
        String imagename = FilenameUtils.removeExtension(selectedFile.getName());
        model.addElement(new Book(selectedFile.getName(), "" + a, imagename, PATH)); //list
        i = i + 1;
        jList2.setModel(model);
        jList2.setCellRenderer(new BookRenderer());
        try {
            copyFileUsingApacheCommonsIO(source, dest); //?
        } catch (IOException ex) {
            Logger.getLogger(MyFormApp.class.getName()).log(Level.SEVERE, null, ex);
        }

        System.out.println("Time taken by Apache Commons IO Copy = " + (System.nanoTime() - start));
    }
}

From source file:e3fraud.gui.MainWindow.java

public void actionPerformed(ActionEvent e) {

    //Handle open button action.
    if (e.getSource() == openButton) {
        int returnVal = fc.showOpenDialog(MainWindow.this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            //parse file
            this.baseModel = FileParser.parseFile(file);
            log.append(currentTime.currentTime() + " Opened: " + file.getName() + "." + newline);
        } else {//ww w .j a  v  a 2  s .  co  m
            log.append(currentTime.currentTime() + " Open command cancelled by user." + newline);
        }
        log.setCaretPosition(log.getDocument().getLength());

        //handle Generate button
    } else if (e.getSource() == generateButton) {
        if (this.baseModel != null) {
            //have the user indicate the ToA via pop-up
            JFrame frame1 = new JFrame("Select Target of Assessment");
            Map<String, Resource> actorsMap = this.baseModel.getActorsMap();
            String selectedActorString = (String) JOptionPane.showInputDialog(frame1,
                    "Which actor's perspective are you taking?", "Choose main actor",
                    JOptionPane.QUESTION_MESSAGE, null, actorsMap.keySet().toArray(),
                    actorsMap.keySet().toArray()[0]);
            if (selectedActorString == null) {
                log.append(currentTime.currentTime() + " Attack generation cancelled!" + newline);
            } else {
                lastSelectedActorString = selectedActorString;
                //have the user select a need via pop-up
                JFrame frame2 = new JFrame("Select graph parameter");
                Map<String, Resource> needsMap = this.baseModel.getNeedsMap();
                String selectedNeedString = (String) JOptionPane.showInputDialog(frame2,
                        "What do you want to use as parameter?", "Choose need to parametrize",
                        JOptionPane.QUESTION_MESSAGE, null, needsMap.keySet().toArray(),
                        needsMap.keySet().toArray()[0]);
                if (selectedNeedString == null) {
                    log.append("Attack generation cancelled!" + newline);
                } else {
                    lastSelectedNeedString = selectedNeedString;
                    //have the user select occurence interval via pop-up
                    JTextField xField = new JTextField("1", 4);
                    JTextField yField = new JTextField("500", 4);
                    JPanel myPanel = new JPanel();
                    myPanel.add(new JLabel("Mininum occurences:"));
                    myPanel.add(xField);
                    myPanel.add(Box.createHorizontalStrut(15)); // a spacer
                    myPanel.add(new JLabel("Maximum occurences:"));
                    myPanel.add(yField);
                    int result = JOptionPane.showConfirmDialog(null, myPanel,
                            "Please Enter occurence rate interval", JOptionPane.OK_CANCEL_OPTION);

                    if (result == JOptionPane.CANCEL_OPTION) {
                        log.append("Attack generation cancelled!" + newline);
                    } else if (result == JOptionPane.OK_OPTION) {
                        startValue = Integer.parseInt(xField.getText());
                        endValue = Integer.parseInt(yField.getText());

                        selectedNeed = needsMap.get(selectedNeedString);
                        selectedActor = actorsMap.get(selectedActorString);

                        //Have a Worker thread to the time-consuming generation and raking (to not freeze the GUI)
                        GenerationWorker generationWorker = new GenerationWorker(baseModel, selectedActorString,
                                selectedActor, selectedNeed, selectedNeedString, startValue, endValue, log,
                                lossButton, gainButton, lossGainButton, gainLossButton, groupingButton,
                                collusionsButton) {
                            //make it so that when Worker is done
                            @Override
                            protected void done() {
                                try {
                                    progressBar.setVisible(false);
                                    System.err.println("I made it invisible");
                                    //the Worker's result is retrieved
                                    treeModel.setRoot(get());
                                    tree.setModel(treeModel);

                                    tree.updateUI();
                                    tree.collapseRow(1);
                                    //tree.expandRow(0);
                                    tree.setRootVisible(false);
                                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                                } catch (InterruptedException | ExecutionException ex) {
                                    Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
                                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                                    log.append("Out of memory; please increase heap size of JVM");
                                    PopUps.infoBox(
                                            "Encountered an error. Most likely out of memory; try increasing the heap size of JVM",
                                            "Error");
                                }
                            }
                        };
                        this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                        progressBar.setVisible(true);
                        progressBar.setIndeterminate(true);
                        progressBar.setString("generating...");
                        generationWorker.addPropertyChangeListener(new PropertyChangeListener() {
                            public void propertyChange(PropertyChangeEvent evt) {
                                if ("phase".equals(evt.getPropertyName())) {
                                    progressBar.setMaximum(100);
                                    progressBar.setIndeterminate(false);
                                    progressBar.setString("ranking...");
                                } else if ("progress".equals(evt.getPropertyName())) {
                                    progressBar.setValue((Integer) evt.getNewValue());
                                }
                            }
                        });
                        generationWorker.execute();
                    }
                }
            }
        } else {
            log.append("Load a model file first!" + newline);
        }
    } //handle the refresh button
    else if (e.getSource() == refreshButton) {
        if (lastSelectedNeedString != null && lastSelectedActorString != null) {
            Map<String, Resource> actorsMap = this.baseModel.getActorsMap();
            Map<String, Resource> needsMap = this.baseModel.getNeedsMap();
            selectedNeed = needsMap.get(lastSelectedNeedString);
            selectedActor = actorsMap.get(lastSelectedActorString);

            //Have a Worker thread to the time-consuming generation and raking (to not freeze the GUI)
            GenerationWorker generationWorker = new GenerationWorker(baseModel, lastSelectedActorString,
                    selectedActor, selectedNeed, lastSelectedNeedString, startValue, endValue, log, lossButton,
                    gainButton, lossGainButton, gainLossButton, groupingButton, collusionsButton) {
                //make it so that when Worker is done
                @Override
                protected void done() {
                    try {
                        progressBar.setVisible(false);
                        //the Worker's result is retrieved
                        treeModel.setRoot(get());
                        tree.setModel(treeModel);
                        tree.updateUI();
                        tree.collapseRow(1);
                        //tree.expandRow(0);
                        tree.setRootVisible(false);
                        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    } catch (InterruptedException | ExecutionException ex) {
                        Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
                        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                        log.append("Most likely out of memory; please increase heap size of JVM");
                        PopUps.infoBox(
                                "Encountered an error. Most likely out of memory; try increasing the heap size of JVM",
                                "Error");
                    }
                }
            };
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            progressBar.setVisible(true);
            progressBar.setIndeterminate(true);
            progressBar.setString("generating...");
            generationWorker.addPropertyChangeListener(new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    if ("phase".equals(evt.getPropertyName())) {
                        progressBar.setMaximum(100);
                        progressBar.setIndeterminate(false);
                        progressBar.setString("ranking...");
                    } else if ("progress".equals(evt.getPropertyName())) {
                        progressBar.setValue((Integer) evt.getNewValue());
                    }
                }
            });
            generationWorker.execute();

        } else {
            log.append(currentTime.currentTime() + " Nothing to refresh. Generate models first" + newline);
        }

    } //handle show ideal graph button
    else if (e.getSource() == idealGraphButton) {
        if (this.baseModel != null) {
            graph1 = GraphingTool.generateGraph(baseModel, selectedNeed, startValue, endValue, true);//expected graph 
            ChartFrame chartframe1 = new ChartFrame("Ideal results", graph1);
            chartframe1.setPreferredSize(new Dimension(CHART_WIDTH, CHART_HEIGHT));
            chartframe1.pack();
            chartframe1.setLocationByPlatform(true);
            chartframe1.setVisible(true);
        } else {
            log.append(currentTime.currentTime() + " Load a model file first!" + newline);
        }
    } //Handle the graph extend button//Handle the graph extend button
    else if (e.getSource() == expandButton) {
        //make sure there is a graph to show
        if (graph2 == null) {
            log.append(currentTime.currentTime() + " No graph to display. Select one first." + newline);
        } else {
            //this makes sure both graphs have the same y axis:
            //            double lowerBound = min(graph1.getXYPlot().getRangeAxis().getRange().getLowerBound(), graph2.getXYPlot().getRangeAxis().getRange().getLowerBound());
            //            double upperBound = max(graph1.getXYPlot().getRangeAxis().getRange().getUpperBound(), graph2.getXYPlot().getRangeAxis().getRange().getUpperBound());
            //            graph1.getXYPlot().getRangeAxis().setRange(lowerBound, upperBound);
            //            graph2.getXYPlot().getRangeAxis().setRange(lowerBound, upperBound);
            chartPane.removeAll();
            chartPanel = new ChartPanel(graph2);
            chartPanel.setPreferredSize(new Dimension(CHART_WIDTH, CHART_HEIGHT));
            chartPane.add(chartPanel);
            chartPane.add(collapseButton);
            extended = true;
            this.setPreferredSize(new Dimension(this.getWidth() + CHART_WIDTH, this.getHeight()));
            JFrame frame = (JFrame) getRootPane().getParent();
            frame.pack();
        }
    } //Handle the graph collapse button//Handle the graph collapse button
    else if (e.getSource() == collapseButton) {
        System.out.println("resizing by -" + CHART_WIDTH);
        chartPane.removeAll();
        chartPane.add(expandButton);
        this.setPreferredSize(new Dimension(this.getWidth() - CHART_WIDTH, this.getHeight()));
        chartPane.repaint();
        chartPane.revalidate();
        extended = false;
        JFrame frame = (JFrame) getRootPane().getParent();
        frame.pack();
    }
}

From source file:com.alvermont.terraj.util.ui.JNLPFileChooser.java

/**
 * Carry out the file open dialog// w  w  w . j a va  2 s. c  o m
 * 
 * @param parent The parent for the dialog
 * @return The result of the user selection
 */
public int showOpenDialog(Component parent) {
    //        if (chooser != null)
    //        {
    int option = chooser.showOpenDialog(parent);

    if (option == JFileChooser.APPROVE_OPTION) {
        File target = addExtension(chooser.getSelectedFile());

        fileContents = new MyFileContents(target);
    } else {
        fileContents = null;
    }
    //        }
    //        else
    //        {
    //            FileOpenService fos;
    //
    //            try
    //            {
    //                fos = (FileOpenService) ServiceManager.lookup(
    //                        "javax.jnlp.FileOpenService");
    //
    //                try
    //                {
    //                    String[] extensions = new String[defaultExtensions.size()];
    //
    //                    defaultExtensions.toArray(extensions);
    //
    //                    fileContents = fos.openFileDialog(null, extensions);
    //                }
    //                catch (IOException ex)
    //                {
    //                    log.error("IOException in open file selection", ex);
    //
    //                    return JFileChooser.ERROR_OPTION;
    //                }
    //            }
    //            catch (UnavailableServiceException e)
    //            {
    //                // we assume that JNLP is not available and some other security manager
    //                // related reason applies
    //                log.error(
    //                    "Couldn't create a file selector or lookup JNLP service", e);
    //
    //                throw new SecurityException(
    //                    "Could not create file selector or use JNLP service", e);
    //            }
    //        }

    if (fileContents != null) {
        return JFileChooser.APPROVE_OPTION;
    } else {
        return JFileChooser.CANCEL_OPTION;
    }
}

From source file:com.civprod.writerstoolbox.OpenNLP.training.TokenizerTrainer.java

private void cmdLoadAbbreviationDictionaryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdLoadAbbreviationDictionaryActionPerformed
    final TokenizerTrainer tempThis = this;
    new Thread(() -> {
        tempThis.setVisible(false);/* ww  w  . j  a  va  2 s.  c o  m*/
        int returnval = myFileChooser.showOpenDialog(tempThis);
        if (returnval == JFileChooser.APPROVE_OPTION) {
            final File selectedFile = myFileChooser.getSelectedFile();
            InputStream DictionaryInputStream = null;
            try {
                DictionaryInputStream = new java.io.BufferedInputStream(new FileInputStream(selectedFile));
                mAbbreviationDictionary = new Dictionary(DictionaryInputStream);
            } catch (IOException ex) {
                Logger.getLogger(DictionaryEditor.class.getName()).log(Level.SEVERE, null, ex);
            } finally {
                if (DictionaryInputStream != null) {
                    try {
                        DictionaryInputStream.close();
                    } catch (IOException ex) {
                        Logger.getLogger(DictionaryEditor.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
        tempThis.setVisible(true);
    }).start();
}

From source file:com.civprod.writerstoolbox.OpenNLP.training.SentenceDetectorTrainer.java

private void cmdLoadAbbreviationDictionaryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdLoadAbbreviationDictionaryActionPerformed
    final SentenceDetectorTrainer tempThis = this;
    new Thread(() -> {
        tempThis.setVisible(false);// www  .  j a  v a 2  s  .  co  m
        int returnval = myFileChooser.showOpenDialog(tempThis);
        if (returnval == JFileChooser.APPROVE_OPTION) {
            final File selectedFile = myFileChooser.getSelectedFile();
            InputStream DictionaryInputStream = null;
            try {
                DictionaryInputStream = new java.io.BufferedInputStream(new FileInputStream(selectedFile));
                mAbbreviationDictionary = new Dictionary(DictionaryInputStream);
            } catch (IOException ex) {
                Logger.getLogger(DictionaryEditor.class.getName()).log(Level.SEVERE, null, ex);
            } finally {
                if (DictionaryInputStream != null) {
                    try {
                        DictionaryInputStream.close();
                    } catch (IOException ex) {
                        Logger.getLogger(DictionaryEditor.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
        tempThis.setVisible(true);
    }).start();
}