Example usage for javax.swing JOptionPane OK_CANCEL_OPTION

List of usage examples for javax.swing JOptionPane OK_CANCEL_OPTION

Introduction

In this page you can find the example usage for javax.swing JOptionPane OK_CANCEL_OPTION.

Prototype

int OK_CANCEL_OPTION

To view the source code for javax.swing JOptionPane OK_CANCEL_OPTION.

Click Source Link

Document

Type used for showConfirmDialog.

Usage

From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_multicastDemand.java

private List<JComponent> getExtraOptions(final int row, final Object itemId) {
    List<JComponent> options = new LinkedList<JComponent>();

    final int numRows = model.getRowCount();
    final NetPlan netPlan = callback.getDesign();
    final List<MulticastDemand> visibleRows = getVisibleElementsInTable();

    JMenuItem offeredTrafficToAll = new JMenuItem("Set offered traffic to all");
    offeredTrafficToAll.addActionListener(new ActionListener() {
        @Override//from w  ww .  j  a v  a  2s  . c  om
        public void actionPerformed(ActionEvent e) {
            double h_d;

            while (true) {
                String str = JOptionPane.showInputDialog(null, "Offered traffic volume",
                        "Set traffic value to all table multicast demands", JOptionPane.QUESTION_MESSAGE);
                if (str == null)
                    return;

                try {
                    h_d = Double.parseDouble(str);
                    if (h_d < 0)
                        throw new RuntimeException();

                    break;
                } catch (Throwable ex) {
                    ErrorHandling.showErrorDialog(
                            "Non-valid multicast demand offered traffic value. Please, introduce a non-negative number",
                            "Error setting link length");
                }
            }

            try {
                for (MulticastDemand demand : visibleRows)
                    demand.setOfferedTraffic(h_d);
                callback.updateVisualizationAfterChanges(
                        Collections.singleton(NetworkElementType.MULTICAST_DEMAND));
                callback.getUndoRedoNavigationManager().addNetPlanChange();
            } catch (Throwable ex) {
                ErrorHandling.showErrorDialog(ex.getMessage(),
                        "Unable to set offered traffic to all multicast demands");
            }
        }
    });

    options.add(offeredTrafficToAll);

    if (itemId != null && netPlan.isMultilayer()) {
        final long demandId = (long) itemId;
        final MulticastDemand demand = netPlan.getMulticastDemandFromId(demandId);
        if (demand.isCoupled()) {
            JMenuItem decoupleDemandItem = new JMenuItem("Decouple multicast demand");
            decoupleDemandItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    demand.decouple();
                    model.setValueAt("", row, COLUMN_COUPLEDTOLINKS);
                    callback.getVisualizationState().resetPickedState();
                    callback.updateVisualizationAfterChanges(
                            Sets.newHashSet(NetworkElementType.MULTICAST_DEMAND, NetworkElementType.LINK));
                    callback.getUndoRedoNavigationManager().addNetPlanChange();
                }
            });

            options.add(decoupleDemandItem);
        }
        if (numRows > 1) {
            JMenuItem decoupleAllDemandsItem = null;
            JMenuItem createUpperLayerLinksFromDemandsItem = null;

            final Set<MulticastDemand> coupledDemands = visibleRows.stream().filter(e -> e.isCoupled())
                    .collect(Collectors.toSet());
            if (!coupledDemands.isEmpty()) {
                decoupleAllDemandsItem = new JMenuItem("Decouple all table demands");
                decoupleAllDemandsItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        for (MulticastDemand d : coupledDemands)
                            d.decouple();
                        int numRows = model.getRowCount();
                        for (int i = 0; i < numRows; i++)
                            model.setValueAt("", i, COLUMN_COUPLEDTOLINKS);
                        callback.getVisualizationState().resetPickedState();
                        callback.updateVisualizationAfterChanges(
                                Sets.newHashSet(NetworkElementType.MULTICAST_DEMAND, NetworkElementType.LINK));
                        callback.getUndoRedoNavigationManager().addNetPlanChange();
                    }
                });
            }

            if (coupledDemands.size() < visibleRows.size()) {
                createUpperLayerLinksFromDemandsItem = new JMenuItem(
                        "Create upper layer links from uncoupled demands");
                createUpperLayerLinksFromDemandsItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        List<Long> layerIds = netPlan.getNetworkLayerIds();
                        final JComboBox layerSelector = new WiderJComboBox();
                        for (long layerId : layerIds) {
                            if (layerId == netPlan.getNetworkLayerDefault().getId())
                                continue;

                            final String layerName = netPlan.getNetworkLayerFromId(layerId).getName();
                            String layerLabel = "Layer " + layerId;
                            if (!layerName.isEmpty())
                                layerLabel += " (" + layerName + ")";

                            layerSelector.addItem(StringLabeller.of(layerId, layerLabel));
                        }

                        layerSelector.setSelectedIndex(0);

                        JPanel pane = new JPanel();
                        pane.add(new JLabel("Select layer: "));
                        pane.add(layerSelector);

                        while (true) {
                            int result = JOptionPane.showConfirmDialog(null, pane,
                                    "Please select the upper layer to create links",
                                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                            if (result != JOptionPane.OK_OPTION)
                                return;

                            try {
                                long layerId = (long) ((StringLabeller) layerSelector.getSelectedItem())
                                        .getObject();
                                NetworkLayer layer = netPlan.getNetworkLayerFromId(layerId);
                                for (MulticastDemand demand : visibleRows)
                                    if (!demand.isCoupled())
                                        demand.coupleToNewLinksCreated(layer);
                                callback.getVisualizationState()
                                        .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals();
                                callback.updateVisualizationAfterChanges(Sets.newHashSet(
                                        NetworkElementType.MULTICAST_DEMAND, NetworkElementType.LINK));
                                callback.getUndoRedoNavigationManager().addNetPlanChange();
                                break;
                            } catch (Throwable ex) {
                                ErrorHandling.showErrorDialog(ex.getMessage(),
                                        "Error creating upper layer links");
                            }
                        }
                    }
                });
            }

            if (!options.isEmpty()
                    && (decoupleAllDemandsItem != null || createUpperLayerLinksFromDemandsItem != null)) {
                options.add(new JPopupMenu.Separator());
                if (decoupleAllDemandsItem != null)
                    options.add(decoupleAllDemandsItem);
                if (createUpperLayerLinksFromDemandsItem != null)
                    options.add(createUpperLayerLinksFromDemandsItem);
            }

        }
    }

    return options;
}

From source file:org.gumtree.vis.awt.time.TimePlotPanel.java

@Override
public void doEditChartProperties() {
    if (selectedDataset != null && selectedSeriesIndex >= 0) {
        Plot1DChartEditor.setSuggestedSeriesKey((String) selectedDataset.getSeriesKey(selectedSeriesIndex));
    }//from   ww  w  . j a va  2 s .  co  m
    TimePlotChartEditor editor = new TimePlotChartEditor(getChart());
    int result = JOptionPane.showConfirmDialog(this, editor,
            localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE);
    if (result == JOptionPane.OK_OPTION) {
        editor.updateChart(getChart());
        updatePlot();
    }
}

From source file:br.com.postalis.folhapgto.proc.TelaPrincipal.java

private void btnImportarLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportarLogActionPerformed
    carregarParametros();/*  w w  w.j  a v  a 2  s .  c  o  m*/
    int confirmacao = JOptionPane.showConfirmDialog(null,
            "Importar Log de processamento ECT para a referncia: " + txtMesAno + "?",
            "Importao do log de processamento", JOptionPane.OK_CANCEL_OPTION);
    if (confirmacao == JOptionPane.OK_OPTION) {
        new Thread() {
            public void run() {
                try {
                    txtStatusProc
                            .setText("Executando importao do log de processamento ECT para a referncia: "
                                    + txtMesAno + "...");
                    btnImportarLog.setEnabled(false);
                    ExitStatus retorno = new SvcFolhaPgtoImpl().consultarLogImportacao(usuario, anoMesRef,
                            dtRef);
                    if (retorno.equals(EnumExistStatus.VAZIO.getStatus())) {
                        txtStatusProc
                                .setText("No exitem lanamentos a importar na referncia: " + txtMesAno + ".");
                        Thread.sleep(10000);
                        txtStatusProc.setText("");
                    } else if (retorno.equals(EnumExistStatus.SUCESSO.getStatus())) {
                        txtStatusProc.setText(
                                "Importao concluida com sucesso para a referncia: " + txtMesAno + ".");
                        Thread.sleep(10000);
                        txtStatusProc.setText("");
                    } else {
                        throw new Exception("O tipo de resultado no esperado: " + retorno.getExitCode());
                    }
                } catch (Exception ex) {
                    String msg = "Erro ao executar a importao do log de processamento para a referncia: "
                            + txtMesAno + ":";
                    LOGGER.error(msg + ex.getMessage());
                    txtStatusProc.setText(msg);
                } finally {
                    btnImportarLog.setEnabled(true);
                }

            }
        }.start();
    }
}

From source file:gui.DownloadManagerGUI.java

@Override
public void actionPerformed(ActionEvent e) {
    JMenuItem clicked = (JMenuItem) e.getSource();

    if (clicked == exportDataItem) {
        //    addNewDownloadDialog.setVisible(true);
    } else if (clicked == importDataItem) {
        //    addNewDownloadDialog.setVisible(true);
    } else if (clicked == exitItem) {
        WindowListener[] listeners = getWindowListeners();
        for (WindowListener listener : listeners)
            listener.windowClosing(new WindowEvent(DownloadManagerGUI.this, 0));
    } else if (clicked == prefsItem) {
        preferenceDialog.setVisible(true);
    } else if (clicked == newDownloadItem) {
        addNewDownloadDialog.setVisible(true);
        addNewDownloadDialog.onPaste();// w  w w. j  a  v a2  s  .com
    } else if (clicked == openItem) {
        downloadPanel.actionOpenFile();
    } else if (clicked == openFolderItem) {
        downloadPanel.actionOpenFolder();
    } else if (clicked == resumeItem) {
        downloadPanel.actionResume();
    } else if (clicked == pauseItem) {
        downloadPanel.actionPause();
        mainToolbar.setStateOfButtonsControl(false, false, false, false, false, true); // canceled
    } else if (clicked == pauseAllItem) {
        int action = JOptionPane.showConfirmDialog(DownloadManagerGUI.this,
                "Do you realy want to pause all downloads?", "Confirm pause all", JOptionPane.OK_CANCEL_OPTION); ////***********
        if (action == JOptionPane.OK_OPTION) {
            downloadPanel.actionPauseAll();
        }
    } else if (clicked == clearItem) {
        downloadPanel.actionClear();
    } else if (clicked == clearAllCompletedItem) {
        downloadPanel.actionClearAllCompleted();
    } else if (clicked == reJoinItem) {
        downloadPanel.actionReJoinFileParts();
    } else if (clicked == reDownloadItem) {
        downloadPanel.actionReDownload();
    } else if (clicked == moveToQueueItem) {
        //        mainToolbarListener.preferencesEventOccured();
    } else if (clicked == removeFromQueueItem) {
        //        mainToolbarListener.preferencesEventOccured();
    } else if (clicked == propertiesItem) {
        downloadPanel.actionProperties();
    } else if (clicked == aboutItem) {
        if (!aboutDialog.isVisible())
            aboutDialog.setVisible(true);
    }
}

From source file:com.freedomotic.jfrontend.MainWindow.java

private void mnuRemoveRoomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuRemoveRoomActionPerformed

    ZoneLogic zone = drawer.getSelectedZone();

    if (zone == null) {
        JOptionPane.showMessageDialog(this, i18n.msg("select_room_first"));
    } else {// w w  w  .  java 2 s.c  o m
        if (JOptionPane.showConfirmDialog(this,
                i18n.msg("really_delete_room_X", new Object[] { zone.getPojo().getName() }),
                i18n.msg("room_delete_confirm_title"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
            drawer.getCurrEnv().removeZone(zone);
            drawer.createHandles(null);
        }
    }
}

From source file:br.com.postalis.folhapgto.proc.TelaPrincipal.java

private void btnPosFolhaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPosFolhaActionPerformed
    carregarParametros();//ww  w  .j  a va2  s . c om
    int confirmacao = JOptionPane.showConfirmDialog(null,
            "Deseja importar os descontos efetuados ps folha para a referncia: " + txtMesAno + "?",
            "Importao ps folha", JOptionPane.OK_CANCEL_OPTION);
    if (confirmacao == JOptionPane.OK_OPTION) {
        new Thread() {
            public void run() {
                try {
                    txtStatusProc
                            .setText("Executando importao ps folha para a referncia: " + txtMesAno + "...");
                    btnPosFolha.setEnabled(false);
                    ExitStatus retorno = new SvcFolhaPgtoImpl().consultarDescPosFolha(usuario, anoMesRef,
                            dtRef);
                    if (retorno.equals(EnumExistStatus.VAZIO.getStatus())) {
                        txtStatusProc.setText(
                                "A importao ps folha no disponvel para a referncia: " + txtMesAno + ".");
                        Thread.sleep(10000);
                        txtStatusProc.setText("");
                    } else if (retorno.equals(EnumExistStatus.SUCESSO.getStatus())) {
                        txtStatusProc.setText(
                                "Importao concluida com sucesso para a referncia: " + txtMesAno + ".");
                        Thread.sleep(10000);
                        txtStatusProc.setText("");
                    } else {
                        throw new Exception("O tipo de resultado no esperado: " + retorno.getExitCode());
                    }
                } catch (Exception ex) {
                    String msg = "Erro ao executar a importao ps folha para a referncia: " + txtMesAno
                            + ": ";
                    LOGGER.error(msg + ex.getMessage());
                    txtStatusProc.setText(msg);
                } finally {
                    btnPosFolha.setEnabled(true);
                }
            }
        }.start();
    }
}

From source file:pi.bestdeal.gui.InterfacePrincipale.java

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
    int idd = (int) jTable3.getModel().getValueAt(jTable3.getSelectedRow(), 0);
    ChoixStat1 chStat = new ChoixStat1();
    ChoixStat2 chStat2 = new ChoixStat2();

    Object[] options = { "BACK", "NEXT" };
    int a = JOptionPane.showOptionDialog(null, chStat, "", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.WARNING_MESSAGE, null, options, options[0]);
    int b = 0;//from   w  w  w. jav  a  2 s  .com
    if (chStat.jRadiosexe.isSelected() && chStat.jRadioconsult.isSelected()) {
        b = 0;
    }
    if (chStat.jRadiosexe.isSelected() && chStat.jRadiores.isSelected()) {
        b = 1;
    }
    if (chStat.jRadiooperation.isSelected() && chStat.jRadioconsult.isSelected()) {
        b = 2;
    }
    if (chStat.jRadiooperation.isSelected() && chStat.jRadiores.isSelected()) {
        b = 3;
    }
    if (a == 1 && b == 2) {
        chStat.setVisible(false);
        Object[] options2 = { "Annuler", "Afficher la Statistique" };
        int c = JOptionPane.showOptionDialog(null, chStat2, "", JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.WARNING_MESSAGE, null, options2, options[0]);
        if (c == 1) {
            java.util.Date d1 = chStat2.jDateDebut.getCalendar().getTime();
            java.sql.Date sqlDate = new java.sql.Date(d1.getTime());
            java.util.Date d2 = chStat2.jDatefin.getCalendar().getTime();
            java.sql.Date sqlDate2 = new java.sql.Date(d2.getTime());
            Charts charts = new Charts();

            XYSeriesCollection dataxy = charts.createDataset(sqlDate.toString(), sqlDate2.toString(), idd);
            final JFreeChart chart = ChartFactory.createXYLineChart(
                    "Evolution des Consultation par rapport au temps", "Jours", "Nombre des Consultations", //
                    dataxy, // Dataset
                    PlotOrientation.VERTICAL, // 

                    true, true, false);
            XYItemRenderer rend = chart.getXYPlot().getRenderer();

            ChartPanel crepart = new ChartPanel(chart);
            Plot plot = chart.getPlot();

            JPanel jpan = new JPanel();
            JButton button = new JButton("Sauvegarder");
            button.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        JFileChooser chooser = new JFileChooser();
                        chooser.showSaveDialog(jPanel3);
                        String path = chooser.getSelectedFile().getPath();
                        if ((!path.contains("jpg")) || (!path.contains("png")) || (!path.contains("jpeg"))) {
                            path = path + ".png";
                        }
                        File f = new File(path);
                        ChartUtilities.saveChartAsPNG(new File(path), chart, 800, 600);

                        if (f.exists() && !f.isDirectory()) {
                            JOptionPane.showMessageDialog(null, "Sauvegarde Effectue");
                            Desktop.getDesktop().open(f);
                        }
                    } catch (IOException ex) {
                        Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            });

            jpan.add(crepart);
            jpan.add(button);
            JOptionPane.showConfirmDialog(null, jpan, "Chart d'volution des consultations",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
        }
    }
    if (a == 1 && (b == 3)) {
        Object[] options2 = { "Annuler", "Afficher la Statistique" };
        int c = JOptionPane.showOptionDialog(null, chStat2, "", JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.WARNING_MESSAGE, null, options2, options[0]);
        if (c == 1) {
            java.util.Date d1 = chStat2.jDateDebut.getCalendar().getTime();
            java.sql.Date sqlDate = new java.sql.Date(d1.getTime());
            java.util.Date d2 = chStat2.jDatefin.getCalendar().getTime();
            java.sql.Date sqlDate2 = new java.sql.Date(d2.getTime());
            Charts charts = new Charts();
            //     JFreeChart chrt = ChartFactory.createXYStepAreaChart(null, null, null, null, PlotOrientation.HORIZONTAL, rootPaneCheckingEnabled, rootPaneCheckingEnabled, rootPaneCheckingEnabled)
            XYSeriesCollection dataxy = charts.createDatasetRes(sqlDate.toString(), sqlDate2.toString(), idd);
            final JFreeChart chart = ChartFactory.createXYLineChart(
                    "Evolution des Consultation par rapport au temps", "Jours", "Nombre des Reservations",
                    dataxy, PlotOrientation.VERTICAL, true, true, false);
            XYItemRenderer rend = chart.getXYPlot().getRenderer();

            ChartPanel crepart = new ChartPanel(chart);
            Plot plot = chart.getPlot();

            JPanel jpan = new JPanel();
            jpan.setLayout(new FlowLayout(FlowLayout.LEADING));
            JButton button = new JButton();

            button.setText("Sauvegarder");
            button.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        JFileChooser chooser = new JFileChooser();
                        chooser.showSaveDialog(jPanel3);
                        String path = chooser.getSelectedFile().getPath();
                        if ((!path.contains("jpg")) || (!path.contains("png")) || (!path.contains("jpeg"))) {
                            path = path + ".png";
                        }
                        File f = new File(path);
                        ChartUtilities.saveChartAsPNG(new File(path), chart, 800, 600);

                        if (f.exists() && !f.isDirectory()) {
                            JOptionPane.showMessageDialog(null, "Sauvegarde Effectue");
                            Desktop.getDesktop().open(f);
                        }
                    } catch (IOException ex) {
                        Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            });

            jpan.add(crepart);
            jpan.add(button);
            JOptionPane.showConfirmDialog(null, jpan, "Test", JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE);
        }

    }
    if (a == 1 && b == 0) {
        ConsultationDAO cdao = ConsultationDAO.getInstance();
        DefaultPieDataset union = new DefaultPieDataset();
        union.setValue("Homme", cdao.consultationCounterByGender(false, idd));
        union.setValue("Femme", cdao.consultationCounterByGender(true, idd));

        final JFreeChart repart = ChartFactory.createPieChart3D("Rpartition par Sexe", union, true, true,
                false);
        ChartPanel crepart = new ChartPanel(repart);
        Plot plot = repart.getPlot();
        JPanel jpan = new JPanel();
        JButton button = new JButton("Sauvegarder");
        button.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    JFileChooser chooser = new JFileChooser();
                    chooser.showSaveDialog(jPanel3);
                    String path = chooser.getSelectedFile().getPath();
                    if ((!path.contains("jpg")) || (!path.contains("png")) || (!path.contains("jpeg"))) {
                        path = path + ".png";
                    }
                    File f = new File(path);
                    ChartUtilities.saveChartAsPNG(new File(path), repart, 800, 600);

                    if (f.exists() && !f.isDirectory()) {
                        JOptionPane.showMessageDialog(null, "Sauvegarde Effectue");
                        Desktop.getDesktop().open(f);
                    }
                } catch (IOException ex) {
                    Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });

        jpan.add(crepart);
        jpan.add(button);
        JOptionPane.showConfirmDialog(null, jpan, "", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);

    }
    if (a == 1 && b == 1) {
        DefaultPieDataset union = new DefaultPieDataset();
        ReservationDAO dAO = ReservationDAO.getInstance();
        union.setValue("Homme", dAO.reservationCounterByGender(false, idd));
        union.setValue("Femme", dAO.reservationCounterByGender(true, idd));

        final JFreeChart repart = ChartFactory.createPieChart3D("Rpartition par Sexe", union, true, true,
                false);
        ChartPanel crepart = new ChartPanel(repart);
        Plot plot = repart.getPlot();
        JPanel jpan = new JPanel();
        JButton button = new JButton("Sauvegarder");
        button.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    JFileChooser chooser = new JFileChooser();
                    chooser.showSaveDialog(jPanel3);
                    String path = chooser.getSelectedFile().getPath();
                    if ((!path.contains("jpg")) || (!path.contains("png")) || (!path.contains("jpeg"))) {
                        path = path + ".png";
                    }
                    File f = new File(path);
                    ChartUtilities.saveChartAsPNG(new File(path), repart, 800, 600);

                    if (f.exists() && !f.isDirectory()) {
                        JOptionPane.showMessageDialog(null, "Sauvegarde Effectue");
                        Desktop.getDesktop().open(f);
                    }
                } catch (IOException ex) {
                    Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });

        jpan.add(crepart);
        jpan.add(button);
        JOptionPane.showConfirmDialog(null, jpan, "Chart de la rpartition des achat par sexe",
                JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);

    }
}

From source file:br.com.postalis.folhapgto.proc.TelaPrincipal.java

private void btnExportarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExportarActionPerformed
    carregarParametros();//  w w  w . ja  v  a  2  s  .  c o m
    int confirmacao = JOptionPane.showConfirmDialog(null,
            "Exportar folha de pagamento para a referncia: " + txtMesAno + "?",
            "Exportao da folha de pagamento", JOptionPane.OK_CANCEL_OPTION);
    if (confirmacao == JOptionPane.OK_OPTION) {
        new Thread() {
            public void run() {
                try {
                    txtStatusProc.setText("Executando exportao para a referncia: " + txtMesAno + "...");
                    btnExportar.setEnabled(false);
                    ExitStatus retorno = new SvcFolhaPgtoImpl().exportarFolhaPgto(usuario, anoMesRef, dtRef);
                    if (retorno.equals(EnumExistStatus.VAZIO.getStatus())) {
                        txtStatusProc
                                .setText("No exitem lanamentos a exportar na referncia: " + txtMesAno + ".");
                        Thread.sleep(10000);
                        txtStatusProc.setText("");
                    } else if (retorno.equals(EnumExistStatus.SUCESSO.getStatus())) {
                        txtStatusProc.setText(
                                "Exportao concluida com sucesso para a referncia: " + txtMesAno + ".");
                        Thread.sleep(10000);
                        txtStatusProc.setText("");
                    } else {
                        throw new Exception("O tipo de resultado no esperado: " + retorno.getExitCode());
                    }
                } catch (Exception ex) {
                    String msg = "Erro ao executar a exportao da folha para a referncia: " + txtMesAno
                            + ": ";
                    LOGGER.error(msg + ex.getMessage());
                    txtStatusProc.setText(msg);
                } finally {
                    preencherTabela();
                    btnExportar.setEnabled(true);
                }

            }
        }.start();
    }
}

From source file:ca.osmcanada.osvuploadr.JPMain.java

private void jbUploadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbUploadActionPerformed
    String path = ca.osmcanada.osvuploadr.JFMain.class.getProtectionDomain().getCodeSource().getLocation()
            .getPath();//from w  ww  .j a  v a  2s.  com
    String decodedPath = "";
    try {
        decodedPath = new File(URLDecoder.decode(path, "UTF-8")).getParentFile().getPath();
    } catch (Exception ex) {
        Logger.getLogger(JPMain.class.getName()).log(Level.SEVERE, "decodePath", ex);
    }
    File id = new File(decodedPath + "/access_token.txt");
    String accessToken = "";
    System.out.println("id_file exists:" + id.exists());
    if (!id.exists()) {
        try {
            String[] buttons = { new String(r.getString("automatically").getBytes(), "UTF-8"),
                    new String(r.getString("manually").getBytes(), "UTF-8"),
                    new String(r.getString("cancel").getBytes(), "UTF-8") };
            int rc = JOptionPane.showOptionDialog(null,
                    new String(r.getString("login_to_osm").getBytes(), "UTF-8"),
                    new String(r.getString("confirmation").getBytes(), "UTF-8"),
                    JOptionPane.INFORMATION_MESSAGE, 0, null, buttons, buttons[0]);
            String token = "";
            System.out.println("GetOSMUser");
            switch (rc) {
            case 0:
                String usr = "";
                String psw = "";
                JTextField tf = new JTextField();
                JPasswordField pf = new JPasswordField();
                rc = JOptionPane.showConfirmDialog(null, tf,
                        new String(r.getString("email_osm_usr").getBytes(), "UTF-8"),
                        JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
                if (rc == JOptionPane.OK_OPTION) {
                    usr = tf.getText();
                } else {
                    return;
                }

                rc = JOptionPane.showConfirmDialog(null, pf,
                        new String(r.getString("enter_password").getBytes(), "UTF-8"),
                        JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
                if (rc == JOptionPane.OK_OPTION) {
                    psw = new String(pf.getPassword());
                } else {
                    return;
                }
                token = GetOSMUser(usr, psw);
                break;
            case 1:
                token = GetOSMUser();
                break;
            case 2:
                return;

            }
            Path targetPath = Paths.get("./access_token.txt");
            byte[] bytes = token.split("\\|")[0].getBytes(StandardCharsets.UTF_8);
            Files.write(targetPath, bytes, StandardOpenOption.CREATE);
            accessToken = token.split("\\|")[0];
            String accessSecret = token.split("\\|")[1];
            SendAuthTokens(accessToken, accessSecret);
        } catch (Exception ex) {
            Logger.getLogger(JPMain.class.getName()).log(Level.SEVERE, "GetOSMUser", ex);
        }
    } else {
        try {
            List<String> token = Files.readAllLines(Paths.get(id.getPath()));
            if (token.size() > 0) {
                accessToken = token.get(0); //read first line
            }
        } catch (Exception ex) {
            Logger.getLogger(JPMain.class.getName()).log(Level.SEVERE, "readAllLines", ex);
        }
    }
    System.out.println("Access Token obtained from file or OSM:" + accessToken);

    //Start processing list
    for (String item : listDir.getItems()) {
        System.out.println("Processing folder:" + item);
        Process(item, accessToken);
    }
    //um = new UploadManager(listDir.getItems());
    //um.start();

}

From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java

private void menuFileNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuFileNewActionPerformed
    if (JOptionPane.showConfirmDialog(this, "Do you really want to start new map?", "Confirmation",
            JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
        resetState();//from  w  ww  .  j ava2  s  . co  m
    }
}