Example usage for javax.swing JOptionPane OK_OPTION

List of usage examples for javax.swing JOptionPane OK_OPTION

Introduction

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

Prototype

int OK_OPTION

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

Click Source Link

Document

Return value form class method if OK is chosen.

Usage

From source file:com.adito.server.Main.java

private boolean fullReset() {
    if (gui) {/*from  w w  w .j ava  2s. c o  m*/
        if (JOptionPane.showConfirmDialog(null, "The embedded configuration database will be\n"
                + "completely deleted and re-created the next\ntime you run the server. Are you absolutely\n"
                + "sure you wish to do this?", "Full Reset", JOptionPane.WARNING_MESSAGE,
                JOptionPane.YES_NO_OPTION) != JOptionPane.OK_OPTION) {
            return false;
        }
    } else {
        System.out.println("The embedded configuration database will be");
        System.out.println("completely deleted and re-created the next");
        System.out.println("time you run the server. Are you absolutely");
        System.out.println("sure you wish to do this?");
        System.out.println();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            System.out.print("(Y)es or (N)o: ");
            String s;
            try {
                s = br.readLine();
                if (s == null) {
                    return false;
                }
                if (s.toLowerCase().equals("y") || s.toLowerCase().equals("yes")) {
                    break;
                }
                if (s.toLowerCase().equals("n") || s.toLowerCase().equals("no")) {
                    return false;
                }
                System.out.println(
                        "\nPlease answer 'y' or 'yes' to perform the reset, or 'n' or 'no' to abort the reset.");
            } catch (IOException e) {
                return false;
            }
        }
    }

    // Start the reset
    System.out.println("Resetting all configuration");
    File[] f = getDBDirectory().listFiles();
    if (f != null) {
        for (int i = 0; i < f.length; i++) {
            if (!f[i].getName().equals("CVS") && !f[i].equals(".cvsignore")) {
                System.out.println("    Deleting " + f[i].getPath());
                if (!f[i].delete()) {
                    System.out.println("        Failed to remove");
                }
            }
        }
    }

    return true;
}

From source file:junk.gui.HazardSpectrumApplication.java

/**
 * This function is to whether to plot ERF_GuiBean or ERF_RupSelectorGuiBean
 * @param e//  ww  w . java 2  s.c  om
 */
void probDeterSelection_actionPerformed(ActionEvent e) {
    String selectedControl = this.probDeterSelection.getSelectedItem().toString();
    if (selectedControl.equalsIgnoreCase(this.PROBABILISTIC)) {
        try {
            this.initERF_GuiBean();
        } catch (RuntimeException ee) {
            JOptionPane.showMessageDialog(this, "Connection to ERF failed", "Internet Connection Problem",
                    JOptionPane.OK_OPTION);
            System.exit(0);
        }
    } else if (selectedControl.equalsIgnoreCase(this.DETERMINISTIC)) {
        try {
            this.initERFSelector_GuiBean();
        } catch (RuntimeException ee) {
            JOptionPane.showMessageDialog(this, "Connection to ERF failed", "Internet Connection Problem",
                    JOptionPane.OK_OPTION);
            System.exit(0);
        }
    }
}

From source file:GUI.MainWindow.java

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

    System.out.println("Edit Hostname Selected");
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) this.VulnTree.getLastSelectedPathComponent();
    if (node == null) {
        return;/*from  w  ww.  j ava  2 s.  c  o m*/
    }

    Object vuln_obj = node.getUserObject();
    if (!(vuln_obj instanceof Vulnerability)) {
        return;
    }

    Vulnerability current = (Vulnerability) vuln_obj;

    int row = this.VulnAffectedHostsTable.getSelectedRow();
    row = this.VulnAffectedHostsTable.convertRowIndexToModel(row);
    Object obj = this.VulnAffectedHostsTable.getModel().getValueAt(row, 0);
    if (obj instanceof Host) {
        Host previous = (Host) obj;

        JTextField hostname = new JTextField();
        hostname.setText(previous.getHostname());
        Object[] message = { "Hostname:", hostname };

        String new_hostname = null;
        while (new_hostname == null) {
            int option = JOptionPane.showConfirmDialog(null, message, "Modify Hostname",
                    JOptionPane.OK_CANCEL_OPTION);
            if (option == JOptionPane.OK_OPTION) {
                new_hostname = hostname.getText();
                Host modified = previous.clone(); // Clone the previous one
                modified.setHostname(new_hostname);
                new TreeUtils().modifyHostname((DefaultMutableTreeNode) this.VulnTree.getModel().getRoot(),
                        previous, modified);
                //current.modifyAffectedHost(previous, modified); // Update the Vulnerability object
                // Update the affected hosts table
                DefaultTableModel dtm = (DefaultTableModel) this.VulnAffectedHostsTable.getModel();
                // Clear the existing table
                dtm.setRowCount(0);

                // Set affected hosts into table
                Enumeration enums = current.getAffectedHosts().elements();
                while (enums.hasMoreElements()) {
                    Object obj2 = enums.nextElement();
                    if (obj instanceof Host) {
                        Host host = (Host) obj2;
                        Vector row2 = host.getAsVector(); // Gets the first two columns from the host
                        dtm.addRow(row2);
                    }
                }

            } else {
                return; // user cancelled or closed the prompt
            }
        }

    }

}

From source file:com.cch.aj.entryrecorder.frame.EntryJFrame.java

private Boolean CheckEntryShift() throws HeadlessException {
    Boolean result = true;/*from ww w . jav a2  s.c o m*/
    if (!this.txtEntrySearch.getText().isEmpty()) {
        AppHelper.defaultShift = this.txtEntrySearch.getText();
    } else {
        JOptionPane.showMessageDialog(this, "Please entry the value of shift", "Warning",
                JOptionPane.OK_OPTION);
        result = false;
    }
    return result;
}

From source file:ca.uviccscu.lp.server.main.MainFrame.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    l.info("Remove game action activated");
    //JOptionPane conf = new JOptionPane();
    if (jTable1.getSelectedRow() >= 0) {
        int result = JOptionPane.showConfirmDialog(rootPane, "Are you sure you want to delete?", "Confirmation",
                2, 3);//w w w. j a  v a2  s. co m
        //JDialog dialog = conf.createDialog(jPanel1, "Are you sure u want to delete?");
        //dialog.show();
        //Object selectedValue = conf.getValue();

        l.trace("Game delete dialog code: " + result);
        if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) {
            l.trace("Game delete cancelled");
        } else if (result == JOptionPane.OK_OPTION) {
            DefaultTableModel mdl = (DefaultTableModel) jTable1.getModel();
            String name = (String) mdl.getValueAt(jTable1.getSelectedRow(), 0);
            if (name != null) {
                l.trace("Removing game: " + name);
                GamelistStorage.removeGame(name);
                SettingsManager.getStorage().removeGame(name);
                mdl.removeRow(jTable1.getSelectedRow());
                l.debug("Game removed: " + name);
            } else {
                mdl.removeRow(jTable1.getSelectedRow());
                l.trace("Empty row - just erasing in table");
            }
        }
    }
    MainFrame.updateGameInterfaceFromStorage();
}

From source file:edu.uara.gui.tableeditor.ChartGenerationFrame.java

private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
    // TODO add your handling code here:
    if (this.cmd_saveChart.isEnabled()) {
        int option = JOptionPane.showConfirmDialog(this, "Chart has been modified! Do you want to save?",
                "Warning", JOptionPane.YES_NO_OPTION);

        switch (option) {
        case JOptionPane.OK_OPTION:
            this.saveFigure();
            break;
        case JOptionPane.NO_OPTION:
            break;
        }/*from   w w w. j  ava  2s  . com*/
    }
}

From source file:co.com.soinsoftware.hotelero.view.JFRoom.java

private void jbtDeleteInvoiceActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jbtDeleteInvoiceActionPerformed
    final List<Invoice> invoiceList = this.getInvoiceListFromTable();
    if (invoiceList != null && this.hasInvoiceToBeDeleted(invoiceList)) {
        final int confirmation = ViewUtils.showConfirmDialog(this, ViewUtils.MSG_DELETE_QUESTION,
                ViewUtils.TITLE_SAVED);/*from  www .  j av a2 s . com*/
        if (confirmation == JOptionPane.OK_OPTION) {
            final RoomStatus roomStatusEnabled = roomStatusController.selectEnabled();
            final InvoiceStatus invoiceStatusDeleted = invoiceStatusController.selectDeleted();
            for (final Invoice invoice : invoiceList) {
                if (invoice.isDelete()) {
                    invoice.setEnabled(false);
                    invoice.setUpdated(new Date());
                    invoice.setRoomStatus(roomStatusEnabled);
                    invoice.setInvoiceStatus(invoiceStatusDeleted);
                    this.invoiceController.save(invoice);
                }
            }
            ViewUtils.showMessage(this, ViewUtils.MSG_DELETED, ViewUtils.TITLE_SAVED,
                    JOptionPane.INFORMATION_MESSAGE);
            this.refreshRoomData();
        }
    } else {
        ViewUtils.showMessage(this, ViewUtils.MSG_UNSELECTED, ViewUtils.TITLE_SAVED,
                JOptionPane.INFORMATION_MESSAGE);
    }
}

From source file:ded.ui.DiagramController.java

/** Delete the selected controllers and associated entities, if any. */
public void deleteSelected() {
    if (this.mode == Mode.DCM_SELECT) {
        IdentityHashSet<Controller> sel = this.getAllSelected();
        int n = sel.size();
        if (n > 1) {
            int choice = JOptionPane.showConfirmDialog(this, "Delete " + n + " elements?", "Confirm Deletion",
                    JOptionPane.OK_CANCEL_OPTION);
            if (choice != JOptionPane.OK_OPTION) {
                return;
            }//  w w w.  j a va2  s  .co  m
        }

        this.deleteControllers(sel);
    }
}

From source file:com.mirth.connect.client.ui.Frame.java

/**
 * Alerts the user with a Ok/cancel option with the passed in 'message'
 *///from   w ww  . ja v  a 2s .co m
public boolean alertOkCancel(Component parentComponent, String message) {
    int option = JOptionPane.showConfirmDialog(getVisibleComponent(parentComponent), message,
            "Select an Option", JOptionPane.OK_CANCEL_OPTION);
    if (option == JOptionPane.OK_OPTION) {
        return true;
    } else {
        return false;
    }
}

From source file:co.com.soinsoftware.hotelero.view.JFRoom.java

private void jbtBookActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jbtBookActionPerformed
    if (this.validateDataForSave()) {
        if (this.validateInitialDate(false, MSG_INITIAL_DATE_TO_BOOK) && this.validateFinalDate()) {
            final int confirmation = ViewUtils.showConfirmDialog(this, ViewUtils.MSG_SAVE_QUESTION,
                    ViewUtils.TITLE_SAVED);
            if (confirmation == JOptionPane.OK_OPTION) {
                this.saveUserInformation();
                final Company company = this.getSelectedCompany();
                final Date initialDate = this.jdcInitialDate.getDate();
                final Date finalDate = this.jdcFinalDate.getDate();
                final String siteFrom = this.jtfSiteFrom.getText();
                final String siteTo = this.jtfSiteTo.getText();
                this.invoiceController.saveBooking(this.user, String.valueOf(this.roomName), initialDate,
                        finalDate, siteFrom, siteTo, company);
                ViewUtils.showMessage(this, ViewUtils.MSG_SAVED, ViewUtils.TITLE_SAVED,
                        JOptionPane.INFORMATION_MESSAGE);
                this.refresh();
            }/* www.  j a va  2s. c om*/
        }
    }
}