Example usage for javax.swing JOptionPane YES_OPTION

List of usage examples for javax.swing JOptionPane YES_OPTION

Introduction

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

Prototype

int YES_OPTION

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

Click Source Link

Document

Return value from class method if YES is chosen.

Usage

From source file:com.mirth.connect.connectors.tcp.TcpListener.java

private void transmissionModeComboBoxActionPerformed() {
    String name = (String) transmissionModeComboBox.getSelectedItem();

    if (!modeLock && transmissionModeProvider != null) {
        if (!transmissionModeProvider.getDefaultProperties().equals(transmissionModeProvider.getProperties())) {
            if (JOptionPane.showConfirmDialog(parent,
                    "Are you sure you would like to change the transmission mode and lose all of the current transmission properties?",
                    "Select an Option", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
                modeLock = true;/*from   w ww  . jav a  2  s  .c o m*/
                transmissionModeComboBox.setSelectedItem(selectedMode);
                modeLock = false;
                return;
            }
        }
    }

    selectedMode = name;
    if (name.equals("Basic TCP")) {
        transmissionModeProvider = new BasicModeClientProvider();
    } else {
        for (TransmissionModePlugin plugin : LoadedExtensions.getInstance().getTransmissionModePlugins()
                .values()) {
            if (plugin.getPluginPointName().equals(name)) {
                transmissionModeProvider = plugin.createProvider();
            }
        }
    }

    if (transmissionModeProvider != null) {
        transmissionModeProvider.initialize(this);
        settingsPlaceHolder.removeAll();
        settingsPlaceHolder.add(transmissionModeProvider.getSettingsComponent());
    }
}

From source file:jeplus.gui.JPanel_TrnsysProjectFiles.java

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

    // Test if the template file is present
    String fn = (String) cboRviFile.getSelectedItem();
    if (fn.startsWith("Select ")) {
        fn = "my.rvx";
    }//from   w w  w.  j a v  a  2 s.  c  o  m
    String templfn = RelativeDirUtil.checkAbsolutePath(txtRviDir.getText() + fn, Project.getBaseDir());
    File ftmpl = new File(templfn);
    if (!ftmpl.exists()) {
        int n = JOptionPane.showConfirmDialog(this,
                "<html><p><center>" + templfn + " does not exist."
                        + "Do you want to copy one from an existing file?</center></p>"
                        + "<p> Alternatively, select 'NO' to create this file. </p>",
                "RVI file not available", JOptionPane.YES_NO_OPTION);
        if (n == JOptionPane.YES_OPTION) {
            // Select a file to open
            if (this.chkReadVar.isSelected()) {
                MainGUI.getFileChooser().setFileFilter(EPlusConfig.getFileFilter(EPlusConfig.RVX));
            } else {
                MainGUI.getFileChooser().setFileFilter(EPlusConfig.getFileFilter(EPlusConfig.RVI));
            }
            MainGUI.getFileChooser().setMultiSelectionEnabled(false);
            MainGUI.getFileChooser().setSelectedFile(new File(""));
            String rvidir = RelativeDirUtil.checkAbsolutePath(txtRviDir.getText(), Project.getBaseDir());
            MainGUI.getFileChooser().setCurrentDirectory(new File(rvidir));
            if (MainGUI.getFileChooser().showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
                File file = MainGUI.getFileChooser().getSelectedFile();
                try {
                    FileUtils.copyFile(file, new File(templfn));
                    cboRviFile.setModel(new DefaultComboBoxModel(new String[] { fn }));
                    Project.setRVIDir(txtRviDir.getText());
                    Project.setRVIFile(fn);
                } catch (IOException ex) {
                    logger.error("Error copying RVX from source.", ex);
                }
            }
            MainGUI.getFileChooser().resetChoosableFileFilters();
            MainGUI.getFileChooser().setSelectedFile(new File(""));
        } else if (n == JOptionPane.NO_OPTION) {

        } else {
            return;
        }
    }
    int idx = MainGUI.getTpnEditors().indexOfTab(fn);
    if (idx >= 0) {
        MainGUI.getTpnEditors().setSelectedIndex(idx);
    } else {
        EPlusEditorPanel RviFilePanel;
        if (FilenameUtils.getExtension(fn).equals("rvx")) {
            RviFilePanel = new EPlusEditorPanel(MainGUI.getTpnEditors(), fn, templfn,
                    EPlusEditorPanel.FileType.RVX, null);
        } else {
            RviFilePanel = new EPlusEditorPanel(MainGUI.getTpnEditors(), fn, templfn,
                    EPlusEditorPanel.FileType.RVI, null);
        }
        int ti = MainGUI.getTpnEditors().getTabCount();
        MainGUI.getTpnEditors().addTab(fn, RviFilePanel);
        RviFilePanel.setTabId(ti);
        MainGUI.getTpnEditors().setSelectedIndex(ti);
        MainGUI.getTpnEditors().setTabComponentAt(ti,
                new ButtonTabComponent(MainGUI.getTpnEditors(), RviFilePanel));
        MainGUI.getTpnEditors().setToolTipTextAt(ti, templfn);
    }

}

From source file:UserInterface.FinanceRole.TransferToRegSiteJPanel.java

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

    //Validation//from   w ww  . j a  v  a  2  s  . co  m
    boolean validationSuccess;
    validationSuccess = validationAutoTansfer();

    if (validationSuccess) {

        objWorldEnterprise.getObjTransactionDirectory().updateTransactionAccount();

        BigDecimal worldDonation = AutoTransfer.transferCheck(objWorldEnterprise, objUserAccount,
                autoDonationAmount);
        BigDecimal worldBalance = objWorldEnterprise.getObjTransactionDirectory().getAvailableRealBalance();
        System.out.println(worldDonation);

        System.out.println(objWorldEnterprise.getObjTransactionDirectory().getAvailableRealBalance());
        System.out.println(objWorldEnterprise.getObjTransactionDirectory().getAvailableVirtualBalance());

        int positiveWorldBalance = worldBalance.compareTo(worldDonation);

        if (positiveWorldBalance >= 1) {
            JDialog.setDefaultLookAndFeelDecorated(true);

            int response = JOptionPane.showConfirmDialog(null,
                    "Total transfer of $ " + worldDonation + "/- Do you want to transfer?", "Confirm",
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (response == JOptionPane.YES_OPTION) {
                System.out.println("Yes button clicked");
                worldDonation = AutoTransfer.transferConfirm(objWorldEnterprise, objUserAccount,
                        autoDonationAmount);

                JOptionPane.showMessageDialog(null, "$ " + worldDonation + "/- transferred successfully");

                autoTransferJTextField.setText(null);

                populateLowRegSiteTable();
            }
        } else {
            JOptionPane.showMessageDialog(null, "World Balance is low");
        }
    }
}

From source file:de.tor.tribes.ui.views.DSWorkbenchFarmManager.java

/**
 * Delete all selected farms/*from  ww  w.ja  va  2  s.c  o m*/
 */
private void deleteSelection() {
    int rows[] = jFarmTable.getSelectedRows();
    if (rows == null || rows.length == 0) {
        showInfo("Keine Farm gewhlt");
        return;
    }

    if (JOptionPaneHelper.showQuestionConfirmBox(this,
            rows.length + " Farm(en) und alle Informationen wirklich lschen?", "Lschen", "Nein",
            "Ja") != JOptionPane.YES_OPTION) {
        return;
    }

    FarmManager.getSingleton().invalidate();
    List<FarmInformation> toDelete = new LinkedList<>();
    for (int row : rows) {
        toDelete.add((FarmInformation) FarmManager.getSingleton().getAllElements()
                .get(jFarmTable.convertRowIndexToModel(row)));
    }

    for (FarmInformation delete : toDelete) {
        FarmManager.getSingleton().removeFarm(delete.getVillage());
    }

    FarmManager.getSingleton().revalidate(true);
    showInfo(rows.length + " Farm(en) gelscht");
}

From source file:org.pegadi.client.ApplicationLauncher.java

protected boolean displayWarning() {
    // JOptionPane warning = new JoptionPane();
    int warning = JOptionPane.showConfirmDialog(this, str.getString("want_to_exit"),
            str.getString("running_applications"), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE);

    if (warning == JOptionPane.YES_OPTION) {
        return true;
    } else {/*  w w w .  j  ava  2  s  . c om*/
        log.info("logout/quit cancelled by user");
        return false;
    } // end if

}

From source file:de.tor.tribes.ui.windows.ReportRulesDialog.java

private void fireDeleteRuleEvent(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_fireDeleteRuleEvent
    ReportRule selection = (ReportRule) jRuleList.getSelectedValue();
    if (selection == null) {
        logger.debug("no rule selected");
        return;//from   ww  w .jav  a  2s.co m
    }

    if (selection.getType() == ReportRule.RuleType.FARM) {
        JOptionPaneHelper.showWarningBox(this, "Diese Regel kann nicht gelscht werden.", "Warnung");
        return;
    }

    if (JOptionPaneHelper.showQuestionConfirmBox(this,
            "Regel '" + selection.getStringRepresentation() + "' wirklich lschen?", "Regel lschen", "Nein",
            "Ja") == JOptionPane.YES_OPTION) {
        logger.debug("Deleting Rule {}", selection.getStringRepresentation());
        ReportManager.getSingleton().removeRule(selection);
        rebuildRuleList();
    }
}

From source file:com._17od.upm.gui.DatabaseActions.java

public void reloadDatabaseBefore(ChangeDatabaseAction editAction)
        throws InvalidPasswordException, ProblemReadingDatabaseFile, IOException {
    boolean proceedWithAction = false;
    if (this.databaseNeedsReload) {
        int answer = JOptionPane.showConfirmDialog(mainWindow, Translator.translate("askReloadDatabase"),
                Translator.translate("reloadDatabase"), JOptionPane.YES_NO_OPTION);
        if (answer == JOptionPane.YES_OPTION) {
            proceedWithAction = reloadDatabaseFromDisk();
        }/*from w  ww .j  a v a2s. c o m*/
    } else {
        proceedWithAction = true;
    }

    if (proceedWithAction) {
        editAction.doAction();
    }
}

From source file:UserInterface.ViewPatientJPanel.java

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

    lblPatientStatus.setText("");
    int selectedRow = tblVitalSigns.getSelectedRow();

    if (selectedRow >= 0) {
        int dialogButton = JOptionPane.YES_NO_OPTION;
        int dialogResult = JOptionPane.showConfirmDialog(null, "Would you like to update this?", "Warning",
                dialogButton);//from  w  ww  . j av a 2s  . c  om

        if (dialogResult == JOptionPane.YES_OPTION) {
            txtRespiratoryRate.setEditable(true);
            txtHeartRate.setEditable(true);
            txtSystolicBloodPressure.setEditable(true);
            txtWeight.setEditable(true);
            btnSaveVS.setEnabled(true);
            btnUpdateVitalSign.setEnabled(false);

        }
    } else {
        JOptionPane.showMessageDialog(null, "Please select a row to update!");
    }
}

From source file:dk.dma.epd.common.prototype.gui.route.RoutePropertiesDialogCommon.java

/**
 * Called when Delete is clicked/*from   www  . ja  va2 s .c  o  m*/
 */
private void onDelete() {
    // Check that there is a selection
    if (selectedWp < 0) {
        return;
    }

    // If the route has two way points or less, delete the entire route
    if (route.getWaypoints().size() < 3) {
        // ... but get confirmation first
        int result = JOptionPane.showConfirmDialog(parent,
                "A route must have at least two waypoints.\nDo you want to delete the route?", "Delete Route?",
                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (result == JOptionPane.YES_OPTION) {
            EPD.getInstance().getRouteManager()
                    .removeRoute(EPD.getInstance().getRouteManager().getRouteIndex(route));
            EPD.getInstance().getRouteManager().notifyListeners(RoutesUpdateEvent.ROUTE_REMOVED);
            dispose();
        }
    }

    else {
        // Update the locked list
        boolean[] newLocked = new boolean[locked.length - 1];
        for (int x = 0; x < newLocked.length; x++) {
            newLocked[x] = locked[x + (x >= selectedWp ? 1 : 0)];
        }
        locked = newLocked;

        // Delete the selected way point
        route.deleteWaypoint(selectedWp);
        adjustStartTime();
        routeTableModel.fireTableDataChanged();
        EPD.getInstance().getRouteManager().notifyListeners(RoutesUpdateEvent.ROUTE_WAYPOINT_DELETED);
    }
}

From source file:com.iucosoft.eavertizare.gui.MainJFrame.java

private void jButtonDeleteFirmaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeleteFirmaActionPerformed
    int index = jListFirma.getSelectedIndex();
    if (index != -1) {
        Object numeFirma = jListFirma.getModel().getElementAt(index);
        firma = firmaDao.findByName((String) numeFirma);

        int rez = JOptionPane.showConfirmDialog(this, "Esti sigur vrei sa sterg firma ?", "Question",
                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

        switch (rez) {
        case JOptionPane.YES_OPTION:

            int idConfiguratie = firma.getConfiguratii().getId();
            firmaDao.dropTableClients(firma.getTabelaClientiLocal());
            System.out.println("conf id = " + idConfiguratie);
            firmaDao.delete(firma.getId());
            configuratiiDao.delete(idConfiguratie);
            JOptionPane.showMessageDialog(this, "Firma stersa cu success", "Succes",
                    JOptionPane.INFORMATION_MESSAGE);
            break;
        case JOptionPane.NO_OPTION:
        case JOptionPane.CLOSED_OPTION:
            break;
        }// w ww  .  ja v a 2s  .c  o m
        refreshFrame();
    } else {
        JOptionPane.showMessageDialog(this, "Selectati firma!", "Info", JOptionPane.INFORMATION_MESSAGE);
    }
}