Example usage for javax.swing JFileChooser setDialogTitle

List of usage examples for javax.swing JFileChooser setDialogTitle

Introduction

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

Prototype

@BeanProperty(preferred = true, description = "The title of the JFileChooser dialog window.")
public void setDialogTitle(String dialogTitle) 

Source Link

Document

Sets the string that goes in the JFileChooser window's title bar.

Usage

From source file:org.n52.ifgicopter.spf.input.GpxInputPlugin.java

/**
 * //from  w w w  . j  a va 2 s.  co m
 */
protected void selectGpxFileAction() {
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            JFileChooser fc = new JFileChooser();
            fc.setDialogTitle("Select GPX File");
            fc.setFileFilter(new FileFilter() {

                @Override
                public boolean accept(File f) {
                    if (f.getName().toLowerCase().endsWith("gpx") || f.getName().toLowerCase().endsWith("xml"))
                        return true;
                    if (f.isDirectory())
                        return true;

                    return false;
                }

                @Override
                public String getDescription() {
                    return "GPX file";
                }
            });
            File gpxfile = new File(getGpxFilePath());
            if (gpxfile.isFile()) {
                fc.setCurrentDirectory(gpxfile.getParentFile());
            }

            int returnVal = fc.showOpenDialog(getUserInterface().getGui());

            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                setGpxFilePath(file.getAbsolutePath());
            } else {
                getLog().debug("Open command cancelled by user.");
            }

            fc = null;
        }
    });
}

From source file:org.n52.ifgicopter.spf.output.GpxOutputPlugin.java

/**
 * /*from w w w  .j  a v  a  2  s .c o m*/
 */
protected void selectGpxFileAction() {
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            JFileChooser fc = new JFileChooser();
            fc.setDialogTitle("Select GPX File");
            fc.setFileFilter(new FileFilter() {

                @Override
                public boolean accept(File f) {
                    if (f.getName().toLowerCase().endsWith("gpx") || f.getName().toLowerCase().endsWith("xml"))
                        return true;
                    if (f.isDirectory())
                        return true;

                    return false;
                }

                @Override
                public String getDescription() {
                    return "GPX file";
                }
            });

            File gpxfile = new File(getGpxFilePath());
            if (gpxfile.isFile()) {
                fc.setCurrentDirectory(gpxfile.getParentFile());
            }

            int returnVal = fc.showOpenDialog(getUserInterface().getGui());

            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                if (!file.getName().endsWith(".gpx") || !file.getName().endsWith(".xml"))
                    setGpxFilePath(file.getAbsolutePath() + ".gpx");
                else
                    setGpxFilePath(file.getAbsolutePath());
            } else {
                log.debug("Open command cancelled by user.");
            }

            fc = null;
        }
    });
}

From source file:org.neo4j.desktop.ui.BrowseForDatabaseActionListener.java

private File fileSelection() {
    File selectedFile = null;// www  . ja v a2s  . co m

    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setFileSelectionMode(DIRECTORIES_ONLY);
    fileChooser.setCurrentDirectory(new File(directoryDisplay.getText()));
    fileChooser.setDialogTitle("Select database");
    fileChooser.setDialogType(CUSTOM_DIALOG);

    int choice = fileChooser.showOpenDialog(frame);

    if (choice == APPROVE_OPTION) {
        selectedFile = fileChooser.getSelectedFile();
    }

    return selectedFile;
}

From source file:org.omegat.gui.align.AlignPanelController.java

/**
 * Display the align tool. The tool is not modal, so this call will return immediately.
 * //from w  w w . ja v  a  2s . co m
 * @param parent
 *            Parent window of the align tool
 */
public void show(Component parent) {
    frame = new AlignMenuFrame();
    frame.setTitle(OStrings.getString("ALIGNER_PANEL"));
    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            closeFrame(frame);
        }
    });

    panel = new AlignPanel();

    ActionListener comparisonListener = e -> {
        ComparisonMode newValue = (ComparisonMode) ((JComboBox<?>) e.getSource()).getSelectedItem();
        if (newValue != aligner.comparisonMode && confirmReset(frame)) {
            aligner.comparisonMode = newValue;
            reloadBeads();
        } else {
            panel.comparisonComboBox.setSelectedItem(aligner.comparisonMode);
        }
    };
    panel.comparisonComboBox.addActionListener(comparisonListener);
    panel.comparisonComboBox.setRenderer(new EnumRenderer<ComparisonMode>("ALIGNER_ENUM_COMPARISON_MODE_"));

    ActionListener algorithmListener = e -> {
        AlgorithmClass newValue = (AlgorithmClass) ((JComboBox<?>) e.getSource()).getSelectedItem();
        if (newValue != aligner.algorithmClass && confirmReset(frame)) {
            aligner.algorithmClass = newValue;
            reloadBeads();
        } else {
            panel.algorithmComboBox.setSelectedItem(aligner.algorithmClass);
        }
    };
    panel.algorithmComboBox.addActionListener(algorithmListener);
    panel.algorithmComboBox.setRenderer(new EnumRenderer<AlgorithmClass>("ALIGNER_ENUM_ALGORITHM_CLASS_"));

    ActionListener calculatorListener = e -> {
        CalculatorType newValue = (CalculatorType) ((JComboBox<?>) e.getSource()).getSelectedItem();
        if (newValue != aligner.calculatorType && confirmReset(frame)) {
            aligner.calculatorType = newValue;
            reloadBeads();
        } else {
            panel.calculatorComboBox.setSelectedItem(aligner.calculatorType);
        }
    };
    panel.calculatorComboBox.addActionListener(calculatorListener);
    panel.calculatorComboBox.setRenderer(new EnumRenderer<CalculatorType>("ALIGNER_ENUM_CALCULATOR_TYPE_"));

    ActionListener counterListener = e -> {
        CounterType newValue = (CounterType) ((JComboBox<?>) e.getSource()).getSelectedItem();
        if (newValue != aligner.counterType && confirmReset(frame)) {
            aligner.counterType = newValue;
            reloadBeads();
        } else {
            panel.counterComboBox.setSelectedItem(aligner.counterType);
        }
    };
    panel.counterComboBox.addActionListener(counterListener);
    panel.counterComboBox.setRenderer(new EnumRenderer<CounterType>("ALIGNER_ENUM_COUNTER_TYPE_"));

    ActionListener segmentingListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            boolean newValue = ((AbstractButton) e.getSource()).isSelected();
            if (newValue != aligner.segment && confirmReset(frame)) {
                aligner.segment = newValue;
                reloadBeads();
            } else {
                panel.segmentingCheckBox.setSelected(aligner.segment);
                frame.segmentingItem.setSelected(aligner.segment);
            }
        }
    };
    panel.segmentingCheckBox.addActionListener(segmentingListener);
    frame.segmentingItem.addActionListener(segmentingListener);

    ActionListener segmentingRulesListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (confirmReset(frame)) {
                SegmentationCustomizer customizer = new SegmentationCustomizer(false, SRX.getDefault(),
                        Core.getSegmenter().getSRX(), null);
                if (customizer.show(frame)) {
                    customizedSRX = customizer.getResult();
                    Core.setSegmenter(new Segmenter(customizedSRX));
                    reloadBeads();
                }
            }
        }
    };
    panel.segmentingRulesButton.addActionListener(segmentingRulesListener);
    frame.segmentingRulesItem.addActionListener(segmentingRulesListener);

    ActionListener filterSettingsListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (confirmReset(frame)) {
                FiltersCustomizer customizer = new FiltersCustomizer(false,
                        FilterMaster.createDefaultFiltersConfig(), Core.getFilterMaster().getConfig(), null);
                if (customizer.show(frame)) {
                    customizedFilters = customizer.getResult();
                    Core.setFilterMaster(new FilterMaster(customizedFilters));
                    aligner.clearLoaded();
                    reloadBeads();
                }
            }
        }
    };
    panel.fileFilterSettingsButton.addActionListener(filterSettingsListener);
    frame.fileFilterSettingsItem.addActionListener(filterSettingsListener);

    TableCellRenderer renderer = new MultilineCellRenderer();
    panel.table.setDefaultRenderer(Object.class, renderer);
    panel.table.setDefaultRenderer(Boolean.class, renderer);
    panel.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            resizeRows(panel.table);
        }
    });

    ActionListener oneAdjustListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int[] rows = panel.table.getSelectedRows();
            int col = panel.table.getSelectedColumn();
            boolean up = e.getSource().equals(panel.moveUpButton) || e.getSource().equals(frame.moveUpItem);
            BeadTableModel model = (BeadTableModel) panel.table.getModel();
            if ((e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0) {
                int trgRow = up ? model.prevBeadFromRow(rows[0]) : model.nextBeadFromRow(rows[rows.length - 1]);
                moveRows(rows, col, trgRow);
            } else {
                int offset = up ? -1 : 1;
                slideRows(rows, col, offset);
            }
        }
    };
    panel.moveUpButton.addActionListener(oneAdjustListener);
    frame.moveUpItem.addActionListener(oneAdjustListener);
    panel.moveDownButton.addActionListener(oneAdjustListener);
    frame.moveDownItem.addActionListener(oneAdjustListener);

    ActionListener mergeListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int[] rows = panel.table.getSelectedRows();
            int col = panel.table.getSelectedColumn();
            BeadTableModel model = (BeadTableModel) panel.table.getModel();
            if (rows.length == 1) {
                rows = new int[] { rows[0], model.nextNonEmptyCell(rows[0], col) };
            }
            int beads = model.beadsInRowSpan(rows);
            if (beads < 1) {
                // Do nothing
            } else if (beads == 1) {
                mergeRows(rows, col);
            } else {
                moveRows(rows, col, rows[0]);
            }
        }
    };
    panel.mergeButton.addActionListener(mergeListener);
    frame.mergeItem.addActionListener(mergeListener);

    ActionListener splitListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int[] rows = panel.table.getSelectedRows();
            int col = panel.table.getSelectedColumn();
            BeadTableModel model = (BeadTableModel) panel.table.getModel();
            int beads = model.beadsInRowSpan(rows);
            if (beads != 1) {
                // Do nothing
            } else if (rows.length == 1) {
                splitRow(rows[0], col);
            } else {
                splitBead(rows, col);
            }
        }
    };
    panel.splitButton.addActionListener(splitListener);
    frame.splitItem.addActionListener(splitListener);

    ActionListener editListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            int row = panel.table.getSelectedRow();
            int col = panel.table.getSelectedColumn();
            editRow(row, col);
        }
    };
    panel.editButton.addActionListener(editListener);
    frame.editItem.addActionListener(editListener);

    ListSelectionListener selectionListener = new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            updateCommandAvailability(panel, frame);
        }
    };
    panel.table.getColumnModel().getSelectionModel().addListSelectionListener(selectionListener);
    panel.table.getSelectionModel().addListSelectionListener(selectionListener);

    ActionListener saveListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (!confirmSaveTMX(panel)) {
                return;
            }
            while (true) {
                JFileChooser chooser = new JFileChooser();
                chooser.setSelectedFile(new File(defaultSaveDir, getOutFileName()));
                chooser.setDialogTitle(OStrings.getString("ALIGNER_PANEL_DIALOG_SAVE"));
                if (JFileChooser.APPROVE_OPTION == chooser.showSaveDialog(frame)) {
                    File file = chooser.getSelectedFile();
                    if (file.isFile()) {
                        if (JOptionPane.OK_OPTION != JOptionPane.showConfirmDialog(frame,
                                StringUtil.format(OStrings.getString("ALIGNER_PANEL_DIALOG_OVERWRITE"),
                                        file.getName()),
                                OStrings.getString("ALIGNER_DIALOG_WARNING_TITLE"),
                                JOptionPane.WARNING_MESSAGE)) {
                            continue;
                        }
                    }
                    List<MutableBead> beads = ((BeadTableModel) panel.table.getModel()).getData();
                    try {
                        aligner.writePairsToTMX(file,
                                MutableBead.beadsToEntries(aligner.srcLang, aligner.trgLang, beads));
                        modified = false;
                    } catch (Exception ex) {
                        Log.log(ex);
                        JOptionPane.showMessageDialog(frame, OStrings.getString("ALIGNER_PANEL_SAVE_ERROR"),
                                OStrings.getString("ERROR_TITLE"), JOptionPane.ERROR_MESSAGE);
                    }
                }
                break;
            }
        }
    };
    panel.saveButton.addActionListener(saveListener);
    frame.saveItem.addActionListener(saveListener);

    ActionListener resetListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (confirmReset(frame)) {
                if (phase == Phase.ALIGN) {
                    aligner.restoreDefaults();
                }
                reloadBeads();
            }
        }
    };
    panel.resetButton.addActionListener(resetListener);
    frame.resetItem.addActionListener(resetListener);

    ActionListener reloadListener = e -> {
        if (confirmReset(frame)) {
            aligner.clearLoaded();
            reloadBeads();
        }
    };
    frame.reloadItem.addActionListener(reloadListener);

    ActionListener removeTagsListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            boolean newValue = ((AbstractButton) e.getSource()).isSelected();
            if (newValue != aligner.removeTags && confirmReset(frame)) {
                aligner.removeTags = newValue;
                aligner.clearLoaded();
                reloadBeads();
            } else {
                panel.removeTagsCheckBox.setSelected(aligner.removeTags);
                frame.removeTagsItem.setSelected(aligner.removeTags);
            }
        }
    };
    panel.removeTagsCheckBox.addActionListener(removeTagsListener);
    frame.removeTagsItem.addActionListener(removeTagsListener);

    panel.continueButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            phase = Phase.EDIT;
            updatePanel();
        }
    });

    ActionListener highlightListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doHighlight = ((AbstractButton) e.getSource()).isSelected();
            updateHighlight();
        }
    };
    panel.highlightCheckBox.addActionListener(highlightListener);
    frame.highlightItem.addActionListener(highlightListener);

    ActionListener highlightPatternListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            PatternPanelController patternEditor = new PatternPanelController(highlightPattern);
            highlightPattern = patternEditor.show(frame);
            Preferences.setPreference(Preferences.ALIGNER_HIGHLIGHT_PATTERN, highlightPattern.pattern());
            updateHighlight();
        }
    };
    panel.highlightPatternButton.addActionListener(highlightPatternListener);
    frame.highlightPatternItem.addActionListener(highlightPatternListener);

    frame.markAcceptedItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setStatus(MutableBead.Status.ACCEPTED, panel.table.getSelectedRows());
        }
    });

    frame.markNeedsReviewItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setStatus(MutableBead.Status.NEEDS_REVIEW, panel.table.getSelectedRows());
        }
    });

    frame.clearMarkItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setStatus(MutableBead.Status.DEFAULT, panel.table.getSelectedRows());
        }
    });

    frame.toggleSelectedItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            toggleEnabled(panel.table.getSelectedRows());
        }
    });

    frame.closeItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            closeFrame(frame);
        }
    });

    frame.keepAllItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            toggleAllEnabled(true);
        }
    });

    frame.keepNoneItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            toggleAllEnabled(false);
        }
    });

    frame.realignPendingItem.addActionListener(e -> {
        realignPending();
    });

    frame.pinpointAlignStartItem.addActionListener(e -> {
        phase = Phase.PINPOINT;
        ppRow = panel.table.getSelectedRow();
        ppCol = panel.table.getSelectedColumn();
        panel.table.clearSelection();
        updatePanel();
    });

    frame.pinpointAlignEndItem.addActionListener(e -> {
        pinpointAlign(panel.table.getSelectedRow(), panel.table.getSelectedColumn());
    });

    frame.pinpointAlignCancelItem.addActionListener(e -> {
        phase = Phase.EDIT;
        ppRow = -1;
        ppCol = -1;
        panel.table.repaint();
        updatePanel();
    });

    panel.table.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (phase == Phase.PINPOINT) {
                JTable table = (JTable) e.getSource();
                int row = table.rowAtPoint(e.getPoint());
                int col = table.columnAtPoint(e.getPoint());
                pinpointAlign(row, col);
            }
        }
    });

    frame.resetItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | KeyEvent.SHIFT_DOWN_MASK));
    frame.realignPendingItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    frame.saveItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    frame.closeItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));

    // emacs-like keys for table navigation
    // See javax.swing.plaf.BasicTableUI.Actions for supported action names.
    setKeyboardShortcut(panel.table, "selectNextRow", 'n');
    setKeyboardShortcut(panel.table, "selectNextRowExtendSelection", 'N');
    setKeyboardShortcut(panel.table, "selectPreviousRow", 'p');
    setKeyboardShortcut(panel.table, "selectPreviousRowExtendSelection", 'P');
    setKeyboardShortcut(panel.table, "selectNextColumn", 'f');
    setKeyboardShortcut(panel.table, "selectNextColumnExtendSelection", 'F');
    setKeyboardShortcut(panel.table, "selectPreviousColumn", 'b');
    setKeyboardShortcut(panel.table, "selectPreviousColumnExtendSelection", 'B');

    panel.table.setTransferHandler(new AlignTransferHandler());
    panel.table.addPropertyChangeListener("dropLocation", new DropLocationListener());
    if (Preferences.isPreference(Preferences.PROJECT_FILES_USE_FONT)) {
        try {
            String fontName = Preferences.getPreference(Preferences.TF_SRC_FONT_NAME);
            int fontSize = Integer.parseInt(Preferences.getPreference(Preferences.TF_SRC_FONT_SIZE));
            panel.table.setFont(new Font(fontName, Font.PLAIN, fontSize));
        } catch (Exception e) {
            Log.log(e);
        }
    }

    // Set initial state
    updateHighlight();
    updatePanel();
    reloadBeads();

    frame.add(panel);
    frame.pack();
    frame.setMinimumSize(frame.getSize());
    frame.setLocationRelativeTo(parent);
    frame.setVisible(true);
}

From source file:org.panbox.desktop.common.vfs.backend.dropbox.DropboxClientIntegration.java

@Override
public File getCurrentSyncDir() throws IOException {
    Settings settings = Settings.getInstance();
    File f = new File(settings.getDropboxSynchronizationDir());
    if (!f.exists() || !f.isDirectory()) {
        // FIXME: this should be handled in a dedicated pane for
        // CSP-specific settings
        int res = JOptionPane.showConfirmDialog(null,
                bundle.getString("DropboxClientIntegration.configureDropboxDir"),
                bundle.getString("DropboxClientIntegration.syncDirLookup"), JOptionPane.YES_NO_OPTION);
        if (res == JOptionPane.YES_OPTION) {
            f = readSyncDirFromMetadata();
            JFileChooser chooser = new JFileChooser();
            chooser.setDialogTitle(bundle.getString("DropboxClientIntegration.syncDir"));
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            chooser.setSelectedFile(f);/*from   w  w  w.j  av a  2 s .c o  m*/
            int ret = chooser.showOpenDialog(null);
            if (ret == JFileChooser.APPROVE_OPTION) {
                f = chooser.getSelectedFile();
                if (f.exists() && f.isDirectory()) {
                    settings.setDropboxSynchronizationDir(f.getAbsolutePath());
                    settings.flush();
                    return f;
                }
            }
        }
    } else {
        return f;
    }
    return null;
}

From source file:org.pmedv.blackboard.commands.CreatePartListCommand.java

@Override
public void execute(ActionEvent e) {
    ApplicationContext ctx = AppContext.getContext();
    final ApplicationWindow win = ctx.getBean(ApplicationWindow.class);
    final BoardEditor editor = EditorUtils.getCurrentActiveEditor();
    StringBuffer partList = new StringBuffer();
    partList.append("Name,Value,Package\n");
    for (Layer layer : editor.getModel().getLayers()) {
        for (Item i : layer.getItems()) {
            if (i instanceof Part && !(i instanceof TextPart)) {
                Part p = (Part) i;/*from www. j av a  2 s. c  o m*/
                partList.append(p.getName() + "," + p.getValue() + "," + p.getPackageType() + "\n");
            }
            if (i instanceof Resistor) {
                Resistor r = (Resistor) i;
                partList.append(r.getName() + "," + r.getValue() + " Ohm,RESISTOR\n");
            }
        }
    }
    final JFileChooser fc = new JFileChooser(".");
    fc.setFileFilter(new CSVFilter());
    fc.setDialogTitle(resources.getResourceByKey("CreatePartListCommand.dialog.subtitle"));
    fc.setApproveButtonText(resources.getResourceByKey("msg.save"));
    int result = fc.showOpenDialog(win);
    if (result == JFileChooser.APPROVE_OPTION) {
        if (fc.getSelectedFile() == null)
            return;
        File selectedFile = fc.getSelectedFile();
        if (selectedFile != null) {
            // if csv extension is missing...
            if (!selectedFile.getName().endsWith(".csv")) {
                selectedFile = new File(selectedFile.getAbsolutePath() + ".csv");
            }
            try {
                FileUtils.writeStringToFile(selectedFile, partList.toString(), "UTF-8");
                int res = JOptionPane.showConfirmDialog(win, resources.getResourceByKey("msg.viewpartlist"),
                        resources.getResourceByKey("msg.question"), JOptionPane.YES_NO_OPTION);
                if (res == JOptionPane.YES_OPTION) {
                    JTextArea textPane = new JTextArea();
                    textPane.setText(partList.toString());
                    JScrollPane s = new JScrollPane(textPane);
                    s.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
                    s.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
                    View v = new View("Partlist for " + editor.getCurrentFile().getName(), null, s);
                    editor.setView(v);
                    final ImageIcon icon = resources.getIcon("icon.document.html");
                    v.getViewProperties().setIcon(icon);
                    v.getViewProperties().setTitle("Partlist for " + editor.getCurrentFile().getName());
                    openEditor(v, editor.getCurrentFile().hashCode());
                    v.undock(new Point(20, 10));
                }
            } catch (IOException e1) {
                ErrorUtils.showErrorDialog(e1);
            }
        }
    }
}

From source file:org.pmedv.blackboard.commands.OpenBoardCommand.java

@Override
public void execute(ActionEvent e) {

    final ApplicationWindow win = ctx.getBean(ApplicationWindow.class);

    // No file selected before, popup a dialog and query the user which file to open.
    if (file == null) {
        String path = System.getProperty("user.home");
        if (AppContext.getLastSelectedFolder() != null) {
            path = AppContext.getLastSelectedFolder();
        }//from  w w w  .j a  va2 s  .co  m
        JFileChooser fc = new JFileChooser(path);
        fc.setDialogTitle(resources.getResourceByKey("OpenBoardCommand.name"));
        fc.setFileFilter(new FefaultFileFilter());
        int result = fc.showOpenDialog(win);
        if (result == JFileChooser.APPROVE_OPTION) {
            if (fc.getSelectedFile() == null)
                return;
            file = fc.getSelectedFile();
            AppContext.setLastSelectedFolder(file.getParentFile().getAbsolutePath());
        } else {
            return;
        }
    }

    final JWindow topWindow = new JWindow();
    topWindow.setSize(390, 50);
    topWindow.setLayout(new BorderLayout());
    topWindow.setBackground(Color.WHITE);

    final JPanel content = new JPanel(new BorderLayout());
    content.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK),
            BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    content.setBackground(Color.WHITE);
    final JLabel infoLabel = new JLabel(
            resources.getResourceByKey("OpenBoardCommand.waitMsg") + " " + file.getName());
    infoLabel.setVerticalAlignment(SwingConstants.CENTER);
    content.add(infoLabel, BorderLayout.SOUTH);

    final JBusyComponent<JPanel> busyPanel = new JBusyComponent<JPanel>(content);
    busyPanel.setBusy(true);

    topWindow.getContentPane().add(busyPanel, BorderLayout.CENTER);
    topWindow.setLocationRelativeTo(null);
    topWindow.add(busyPanel, BorderLayout.CENTER);

    final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {

        @Override
        protected Boolean doInBackground() {
            topWindow.setVisible(true);
            doOpen();
            return Boolean.valueOf(true);
        }

        @Override
        protected void done() {
            topWindow.setVisible(false);
            topWindow.dispose();
            for (Runnable r : postConfigurators) {
                SwingUtilities.invokeLater(r);
            }
        }
    };

    worker.execute();

}

From source file:org.pmedv.blackboard.commands.SaveNetlistCommand.java

@Override
public void execute(ActionEvent e) {

    ApplicationContext ctx = AppContext.getContext();
    final ApplicationWindow win = ctx.getBean(ApplicationWindow.class);

    String path = System.getProperty("user.home");
    if (AppContext.getLastSelectedFolder() != null) {
        path = AppContext.getLastSelectedFolder();
    }// w  w  w.j  a v a  2  s.c om

    final JFileChooser fc = new JFileChooser(path);

    fc.setDialogTitle(resources.getResourceByKey("SaveNetlistCommand.dialog.subtitle"));
    fc.setApproveButtonText(resources.getResourceByKey("msg.save"));

    int result = fc.showOpenDialog(win);

    if (result != JFileChooser.APPROVE_OPTION) {
        return;
    }

    if (fc.getSelectedFile() == null)
        return;

    File selectedFile = fc.getSelectedFile();

    AppContext.setLastSelectedFolder(selectedFile.getParentFile().getAbsolutePath());

    if (selectedFile.exists()) {
        result = JOptionPane.showConfirmDialog(win, resources.getResourceByKey("msg.warning.fileexists"),
                resources.getResourceByKey("msg.warning"), JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE);

        if (result == JOptionPane.NO_OPTION) {
            return;
        }
    }

    if (selectedFile != null && netlist != null) {
        try {
            FileUtils.writeStringToFile(selectedFile, netlist);
        } catch (IOException e1) {
            ErrorUtils.showErrorDialog(e1);
        }

    }

}

From source file:org.scify.talkandplay.gui.configuration.EntertainmentTab.java

private void setListeners() {

    musicPathTextField.addMouseListener(new MouseAdapter() {
        @Override/*from   w  w w .  ja  v a2 s  . c  o  m*/
        public void mouseClicked(MouseEvent me) {
            JFileChooser chooser = new JFileChooser();

            chooser.setDialogTitle(" ");
            chooser.setAcceptAllFileFilterUsed(false);
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
                musicPathTextField.setText(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });

    videoPathTextField.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent me) {
            JFileChooser chooser = new JFileChooser();

            chooser.setDialogTitle(" ");
            chooser.setAcceptAllFileFilterUsed(false);
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
                videoPathTextField.setText(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });

    musicPathTextField.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent fe) {
            if (" ".equals(musicPathTextField.getText())) {
                musicPathTextField.setText("");
            }
        }

        public void focusLost(FocusEvent fe) {
            if (musicPathTextField.getText().isEmpty()) {
                musicPathTextField.setText(" ");
            } else if (!musicPathTextField.getText().endsWith("/")) {
                musicPathTextField.setText(musicPathTextField.getText() + "/");
            }
        }
    });

    videoPathTextField.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent fe) {
            if (" video".equals(videoPathTextField.getText())) {
                videoPathTextField.setText("");
            }
        }

        public void focusLost(FocusEvent fe) {
            if (videoPathTextField.getText().isEmpty()) {
                videoPathTextField.setText(" video");
            } else if (!videoPathTextField.getText().endsWith("/")) {
                videoPathTextField.setText(videoPathTextField.getText() + "/");
            }
        }
    });

    songSumTextField.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent fe) {
            if ("".equals(songSumTextField.getText())) {
                songSumTextField.setText("");
            }
        }

        public void focusLost(FocusEvent fe) {
            if (songSumTextField.getText().isEmpty()) {
                songSumTextField.setText("");
            }
        }
    });

    backButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent me) {
            parent.goBack();
        }
    });
}

From source file:org.scify.talkandplay.gui.users.UserFormPanel.java

private void uploadImageLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_uploadImageLabelMouseClicked
    userImage = "";
    JFileChooser chooser = new JFileChooser();

    chooser.setDialogTitle(" ");
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setFileFilter(/*  ww  w.  j av a 2 s.  co m*/
            new FileNameExtensionFilter("Image Files", "png", "jpg", "jpeg", "JPG", "JPEG", "gif"));
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
        userImage = chooser.getSelectedFile().getAbsolutePath();
        uploadImageLabel.setIcon(guiHelper.getIcon(userImage));
    }
}