Example usage for javax.swing JOptionPane DEFAULT_OPTION

List of usage examples for javax.swing JOptionPane DEFAULT_OPTION

Introduction

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

Prototype

int DEFAULT_OPTION

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

Click Source Link

Document

Type meaning Look and Feel should not supply any options -- only use the options from the JOptionPane.

Usage

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

private void buttonCloudTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCloudTestActionPerformed
        //  ??? //from w  ww.  j a v a2s .  c o m
        final StringBuilder sb = new StringBuilder(getLocaleMessage("admin.cloud_test_dialog.results") + ":\n");
        try {
            for (final IPing event : ServiceLoader.load(IPing.class)) {
                if (event.getUID() == 01L) {
                    QLog.l().logger().info(
                            " SPI ??. ?: " + event.getDescription());
                    sb.append(event.getDescription()).append(" ")
                            .append(getLocaleMessage("admin.cloud_test_dialog.result")).append(": ")
                            .append(event.ping()).append("\n");
                }
            }
        } catch (Throwable ex) {
            QLog.l().logger().error("SPI error: ", ex);
            sb.append(getLocaleMessage("admin.cloud_test_dialog.error"));
        }
        final String res = "URL=\"" + ServerProps.getInstance().getProps().getSkyServerUrl() + "\"\n\n"
                + sb.toString();
        sb.setLength(0);
        JOptionPane.showConfirmDialog(null, res, getLocaleMessage("admin.cloud_test_dialog.title"),
                JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE);
    }

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

private void buttonSendDataToSkyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSendDataToSkyActionPerformed
        //  ??? /*from   ww  w.j  a  va2 s  .c o m*/
        final Thread th = new Thread(() -> {
            int all = 0;
            all = QServiceTree.getInstance().getNodes().stream().filter((service) -> (service.isLeaf()))
                    .map((_item) -> 1).reduce(all, Integer::sum);
            all += QUserList.getInstance().getSize();
            int tmp = 0;
            try {
                for (final IDataExchange event : ServiceLoader.load(IDataExchange.class)) {
                    QLog.l().logger().info(
                            " SPI ??. ?: " + event.getDescription());
                    for (QService service : QServiceTree.getInstance().getNodes()) {
                        if (service.isLeaf()) {
                            event.sendServiceName(ServerProps.getInstance().getProps().getBranchOfficeId(),
                                    service.getId(), service.getName());
                            tmp++;
                            final String s = "" + tmp + "/" + all + "  " + tmp * 100 / all + "%";
                            SwingUtilities.invokeLater(() -> {
                                buttonSendDataToSky.setText(s);
                            });
                        }
                    }
                    for (QUser user : QUserList.getInstance().getItems()) {
                        event.sendUserName(ServerProps.getInstance().getProps().getBranchOfficeId(), user.getId(),
                                user.getName());
                        tmp++;
                        final String s = "" + tmp + "/" + all + "  " + tmp * 100 / all + "%";
                        SwingUtilities.invokeLater(() -> {
                            buttonSendDataToSky.setText(s);
                        });
                    }
                }
            } catch (Throwable ex) {
                QLog.l().logger().error("? ? ?  .", ex);
                JOptionPane.showConfirmDialog(null,
                        getLocaleMessage("admin.cloud_senddata_dialog.message_err") + "\n" + ex.getMessage(),
                        getLocaleMessage("admin.cloud_senddata_dialog.title"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            }
            JOptionPane.showConfirmDialog(null,
                    getLocaleMessage("admin.cloud_senddata_dialog.message") + " " + tmp + "/" + all,
                    getLocaleMessage("admin.cloud_senddata_dialog.title"), JOptionPane.DEFAULT_OPTION,
                    JOptionPane.INFORMATION_MESSAGE);
            SwingUtilities.invokeLater(() -> {
                buttonSendDataToSky.setText(getLocaleMessage("buttonSendDataToSky.text"));
            });
        });
        th.start();

    }

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

private void buttonCheckZoneBoardServActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCheckZoneBoardServActionPerformed
        //  ??? //from   w ww . j  a  va 2 s  . c  o m
        final StringBuilder sb = new StringBuilder(getLocaleMessage("admin.zoneboard_test_dialog.results") + ":\n");
        try {
            for (final IPing event : ServiceLoader.load(IPing.class)) {
                if (event.getUID() == 02L) {
                    QLog.l().logger().info(
                            " SPI ??. ?: " + event.getDescription());
                    sb.append(event.getDescription()).append(" ")
                            .append(getLocaleMessage("admin.zoneboard_test_dialog.result")).append(": ")
                            .append(event.ping()).append("\n");
                }
            }
        } catch (Throwable ex) {
            QLog.l().logger()
                    .error("    ?. ", ex);
            sb.append(getLocaleMessage("admin.zoneboard_test_dialog.error"));
        }
        final String res = sb.toString();
        sb.setLength(0);
        JOptionPane.showConfirmDialog(null, res, getLocaleMessage("admin.zoneboard_test_dialog.title"),
                JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE);

    }

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

@Action
    public void addRespItem() {
        // ?    ?  ,  
        String respName = getLocaleMessage("admin.add_resp_dialog.info");
        boolean flag = true;
        while (flag) {
            respName = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.add_resp_dialog.message"),
                    getLocaleMessage("admin.add_resp_dialog.title"), 3, null, null, respName);
            if (respName == null) {
                return;
            }//from  w ww.j  a  v a  2 s  .  co m
            if ("".equals(respName)) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_resp_dialog.err1.message"),
                        getLocaleMessage("admin.add_resp_dialog.err1.title"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (respName.indexOf('\"') != -1) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_resp_dialog.err2.message"),
                        getLocaleMessage("admin.add_resp_dialog.err2.title"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (respName.length() > 100) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_resp_dialog.err3.message"),
                        getLocaleMessage("admin.add_resp_dialog.err3.title"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else {
                flag = false;
            }
        }
        QLog.l().logger().debug("?  \"" + respName + "\"");
        final QRespItem item = new QRespItem();
        item.setName(respName);
        item.setHTMLText(
                "<html><b><p align=center><span style='font-size:20.0pt;color:green'>" + respName + "</span></b>");
        QResponseList.getInstance().addElement(item);
        listResponse.setSelectedValue(item, true);
    }

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

@Action
    public void addSchedule() {
        // ?    ?  ,  
        String scheduleName = getLocaleMessage("admin.add_work_plan_dialog.info");
        boolean flag = true;
        while (flag) {
            scheduleName = (String) JOptionPane.showInputDialog(this,
                    getLocaleMessage("admin.add_work_plan_dialog.message"),
                    getLocaleMessage("admin.add_work_plan_dialog.title"), 3, null, null, scheduleName);
            if (scheduleName == null) {
                return;
            }//from  w  w w  .j a  v  a  2 s  . c o m
            if ("".equals(scheduleName)) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_work_plan_dialog.err1.message"),
                        getLocaleMessage("admin.add_work_plan_dialog.err1.title"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (scheduleName.indexOf('\"') != -1) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_work_plan_dialog.err2.message"),
                        getLocaleMessage("admin.add_work_plan_dialog.err2.title"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (scheduleName.length() > 150) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_work_plan_dialog.err3.message"),
                        getLocaleMessage("admin.add_work_plan_dialog.err3.title"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else {
                flag = false;
            }
        }
        QLog.l().logger().debug("?  \"" + scheduleName + "\"");
        final QSchedule item = new QSchedule();
        item.setName(scheduleName);
        item.setType(0);
        QScheduleList.getInstance().addElement(item);
        listSchedule.setSelectedValue(item, true);
    }

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

@Action
    public void addResult() {
        String resultText = "";
        boolean flag = true;
        while (flag) {
            resultText = (String) JOptionPane.showInputDialog(this,
                    getLocaleMessage("admin.add_result_dialog.message"),
                    getLocaleMessage("admin.add_result_dialog.title"), 3, null, null, resultText);
            if (resultText == null) {
                return;
            }//w ww . ja v a2s .  c  o  m
            if ("".equals(resultText)) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_result_dialog.err1.message"),
                        getLocaleMessage("admin.add_result_dialog.err1.title"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (resultText.indexOf('\"') != -1) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_result_dialog.err2.message"),
                        getLocaleMessage("admin.add_result_dialog.err2.title"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (resultText.length() > 150) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_result_dialog.err3.message"),
                        getLocaleMessage("admin.add_result_dialog.err3.title"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else {
                flag = false;
            }
        }
        QLog.l().logger().debug("?  \"" + resultText + "\"");
        final QResult item = new QResult();
        item.setName(resultText);
        QResultList.getInstance().addElement(item);
        listResults.setSelectedValue(item, true);
    }

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

@Action
    public void addCalendar() {
        // ?  ?  ?  ,  
        String calendarName = getLocaleMessage("admin.add_calendar_dialog.info");
        boolean flag = true;
        while (flag) {
            calendarName = (String) JOptionPane.showInputDialog(this,
                    getLocaleMessage("admin.add_calendar_dialog.message"),
                    getLocaleMessage("admin.add_calendar_dialog.title"), 3, null, null, calendarName);
            if (calendarName == null) {
                return;
            }/*from   ww  w.  ja  v  a 2s . co m*/
            if ("".equals(calendarName)) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_calendar_dialog.err1.message"),
                        getLocaleMessage("admin.add_calendar_dialog.err1.title"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (calendarName.indexOf('\"') != -1) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_calendar_dialog.err2.message"),
                        getLocaleMessage("admin.add_calendar_dialog.err2.title"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (calendarName.length() > 150) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_calendar_dialog.err3.message"),
                        getLocaleMessage("admin.add_calendar_dialog.err3.title"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else {
                flag = false;
            }
        }
        QLog.l().logger().debug("?  \"" + calendarName + "\"");
        final QCalendar item = new QCalendar();
        item.setName(calendarName);
        QCalendarList.getInstance().addElement(item);
        listCalendar.setSelectedValue(item, true);
    }

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

@Action
    public void addBreakToList() {
        // ?    ?  ,  
        String breaksName = getLocaleMessage("admin.add_breaks_dialog.info");
        boolean flag = true;
        while (flag) {
            breaksName = (String) JOptionPane.showInputDialog(this,
                    getLocaleMessage("admin.add_breaks_dialog.message"),
                    getLocaleMessage("admin.add_breaks_dialog.title"), 3, null, null, breaksName);
            if (breaksName == null) {
                return;
            }/*from w  w  w  . j a  va  2 s  .c  o m*/
            for (QBreaks qb : QBreaksList.getInstance().getItems()) {
                if (qb.getName().equalsIgnoreCase(breaksName)) {
                    JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.enter_sute_mark.err2.title"),
                            getLocaleMessage("admin.enter_sute_mark.err1.title"), JOptionPane.DEFAULT_OPTION,
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }
            if ("".equals(breaksName)) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_breaks_dialog.err1.message"),
                        getLocaleMessage("admin.add_work_plan_dialog.err1.title"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (breaksName.indexOf('\"') != -1) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_breaks_dialog.err2.message"),
                        getLocaleMessage("admin.add_work_plan_dialog.err2.title"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (breaksName.length() > 150) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_breaks_dialog.err3.message"),
                        getLocaleMessage("admin.add_work_plan_dialog.err3.title"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else {
                flag = false;
            }
        }
        QLog.l().logger().debug("?  \"" + breaksName + "\"");
        final QBreaks item = new QBreaks();
        item.setName(breaksName);
        QBreaksList.getInstance().addElement(item);
        listBreaks.setSelectedValue(item, true);
    }

From source file:net.team2xh.crt.gui.util.GUIToolkit.java

/**
 * Displays a dialog with "OK" button./*from  w  w  w. ja v a  2s . com*/
 *
 * @param parent  Parent window
 * @param message Message (can contain "\n" characters)
 * @param title   Dialog title
 * @param type    Icon type (use JOptionPane static values)
 */
public static void showOkDialog(java.awt.Window parent, String message, String title, int type) {
    SwingUtilities.invokeLater(() -> {
        Object[] options = { "OK" };
        JLabel msg = new JLabel(convertToMultiline(message));
        Dimension sz = msg.getPreferredSize();
        msg.setPreferredSize(new Dimension(sz.width + 20, sz.height));
        JOptionPane.showOptionDialog(parent, msg, title, JOptionPane.DEFAULT_OPTION, type, null, options,
                options[0]);
    });
}

From source file:nl.detoren.ijsco.ui.Mainscreen.java

public void ShowWarning(String warning) {
    /*      JPanel p = new JPanel(new BorderLayout());
          DefaultTableModel tableModel = new DefaultTableModel();
          tableModel.addColumn("Selection", new Object[] { "A", "B", "C" });
            /*from   w ww  .  ja v  a  2s  .c om*/
          JTable table = new JTable(tableModel);
          ListSelectionModel selectionModel = table.getSelectionModel();
          p.add(table, BorderLayout.CENTER);
    */
    Object[] options = { "OK" };
    int option = JOptionPane.showOptionDialog(null, warning, "Warning", JOptionPane.DEFAULT_OPTION,
            JOptionPane.WARNING_MESSAGE, null, options, options[0]);

    //int option = JOptionPane.showConfirmDialog(null, warning, "Warning", , JOptionPane.ERROR_MESSAGE);
    if (option == 0) {
        return;
    }

}