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.sshtools.powervnc.PowerVNCPanel.java

public void authenticationComplete(boolean newProfile) throws SshException,

        IOException {/*from   w w w.  ja  va  2 s  . co  m*/

    //     System.out.println("giga");
    statusBar.setStatusText("User authenticated");
    setContainerTitle(getCurrentConnectionProfile().getHost());

    int localPort = 0;

    String host = getCurrentConnectionProfile().getApplicationProperty(PROFILE_PROPERTY_VNC_HOST, "localhost");
    /*
        String port = getCurrentConnectionProfile()
            .getApplicationProperty(
            PROFILE_PROPERTY_VNC_DISPLAY,
            "5900");
    */
    //    String host = "192.168.0.3";
    String port = PowerVNC.DISPLAY;

    final VNCDisplay display = new VNCDisplay(host + ":" + port, 5900);

    final String addr = "0.0.0.0";

    String command = getCurrentConnectionProfile().getApplicationProperty(

            PROFILE_PRE_VNC_COMMAND, null);

    if (command != null && command.trim().length() > 0) {

        statusBar.setStatusText("Executing command: " + command);
        remove(vnc);
        add(terminal, BorderLayout.CENTER);

        emulation.reset();
        emulation.clearScreen();
        emulation.setCursorPosition(0, 0);
        terminal.refresh();

        log.debug("Executing pre VNC command" + command);

        SessionChannelClient session = ssh.openSessionChannel();

        session.requestPseudoTerminal("vt100", 80, 24, 0, 0, "");

        if (session.executeCommand(command)) {

            session.bindInputStream(emulation.getTerminalInputStream());
            session.bindOutputStream(emulation.getTerminalOutputStream());
        }

        try {

            session.getState().waitForState(ChannelState.CHANNEL_CLOSED);

        }

        catch (InterruptedException ex) {

        } finally {

            remove(terminal);
            //        Rectangle r = new Rectangle(vnc.getWidth(), vnc.getHeight());
            ////        vnc.getSize().
            //        setFrameResizeable(true);
            //        setBounds(r);
            //        refresh();
            add(vnc, BorderLayout.CENTER);
            //        JFrame desktop = new JFrame();
            //        desktop.add(vnc, BorderLayout.CENTER);
            //        desktop.pack();
            //              pack();
        }

    }

    statusBar.setStatusText("Setting up VNC forwarding");

    if (log.isDebugEnabled()) {

        log.debug("Setting up forwarding on " + addr

                + " (" + localPort + ") to " + display.getHost()

                + ":" + display.getPort());

    }

    final PowerVNCOptions options =

            new PowerVNCOptions(getCurrentConnectionProfile());

    statusBar.setStatusText("Initialising VNC");

    ForwardingConfiguration config =

            new ForwardingConfiguration(

                    "VNC",

                    "forwarded-channel",

                    0,

                    display.getHost(),

                    display.getPort());

    channel =

            new ForwardingIOChannel(

                    ForwardingIOChannel.LOCAL_FORWARDING_CHANNEL,

                    "VNC",

                    config.getHostToConnect(),

                    config.getPortToConnect(),

                    addr,

                    display.getPort());

    if (ssh.openChannel(channel)) {

        // The forwarding channel is open so forward to the
        // VNC protocol

        channel.addEventListener(new DataNotificationListener(statusBar));

        if (newProfile) {

            setNeedSave(true);

        }

        new SshThread(new Runnable() {

            public void run() {

                //           setBounds(new Rectangle(1000, 1000));
                //           setVisible(true);
                //           setPreferredSize(new Dimension(1000, 1000));
                //           revalidate();
                //           pack();
                //           this.setsize(new Dimension(1000, 1000));
                initVNC(

                        channel.getInputStream(),

                        channel.getOutputStream(),

                        options);

            }

        }

                , "VNC", true).start();
        //      setBounds(new Rectangle(1000, 1000));
        setSize(800, 800);
        //      show();
        //      setSize(new Dimension(1000, 1000));
        //      revalidate();
        //      resize(800, 800);
        //      refresh();
    }

    else {

        // We need to close the connection and inform the user

        // that the forwarding failed to start

        try {

            SwingUtilities.invokeAndWait(new Runnable() {

                public void run() {

                    JOptionPane.showMessageDialog(

                            PowerVNCPanel.this,

                            "Powua failed to open a forwarding channel to "

                                    + display.toString(),

                            "Powua",

                            JOptionPane.OK_OPTION);

                }

            });

        }

        catch (Exception ex) {

            statusBar.setStatusText(

                    "Could not connect to local forwarding server");

        }

        finally {

            closeConnection(true);

        }

    }

}

From source file:org.micromanager.CRISP.CRISPFrame.java

private void CalibrateButton_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CalibrateButton_ActionPerformed
    try {//from ww w .  j  a v a  2 s .c o  m
        core_.setProperty(CRISP_, "CRISP State", "loG_cal");

        String state = "";
        int counter = 0;
        while (!state.equals("loG_cal") && counter < 50) {
            state = core_.getProperty(CRISP_, "CRISP State");
            Thread.sleep(100);
        }
        Double snr = new Double(core_.getProperty(CRISP_, "Signal Noise Ratio"));

        if (snr < 2.0)
            ReportingUtils.showMessage("Signal Noise Ratio is smaller than 2.0.  "
                    + "Focus on your sample, increase LED intensity and try again.");

        core_.setProperty(CRISP_, "CRISP State", "Dither");

        String value = core_.getProperty(CRISP_, "Dither Error");

        final JLabel jl = new JLabel();
        final JLabel jlA = new JLabel();
        final JLabel jlB = new JLabel();
        final String msg1 = "Value:  ";
        final String msg2 = "Adjust the detector lateral adjustment screw until the value is > 100 or"
                + "< -100 and stable.";
        jlA.setText(msg1);
        jl.setText(value);
        jl.setAlignmentX(JLabel.CENTER);

        Object[] msg = { msg1, jl, msg2 };

        ActionListener al = new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                try {
                    jl.setText(core_.getProperty(CRISP_, "Dither Error"));
                } catch (Exception ex) {
                    ReportingUtils.logError("Error while getting CRISP dither Error");
                }
            }
        };

        Timer timer = new Timer(100, al);
        timer.setInitialDelay(500);
        timer.start();

        /*JOptionPane optionPane = new JOptionPane(new JLabel("Hello World",JLabel.CENTER));
        JDialog dialog = optionPane.createDialog("");
        dialog.setModal(true);
        dialog.setVisible(true); */

        JOptionPane.showMessageDialog(null, msg, "CRISP Calibration", JOptionPane.OK_OPTION);

        timer.stop();

        core_.setProperty(CRISP_, "CRISP State", "gain_Cal");

        counter = 0;
        while (!state.equals("Ready") && counter < 50) {
            state = core_.getProperty(CRISP_, "CRISP State");
            Thread.sleep(100);
        }
        // ReportingUtils.showMessage("Calibration failed. Focus, make sure that the NA variable is set correctly and try again.");

    } catch (Exception ex) {
        ReportingUtils.showMessage(
                "Calibration failed. Focus, make sure that the NA variable is set correctly and try again.");
    }
}

From source file:sk.uniza.fri.pds.spotreba.energie.gui.MainGui.java

private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
    final ReportParams params = new ReportParams();
    int option = showUniversalInputDialog(params, "Ro?n sprva pre zkaznka", new Dimension(400, 80));
    if (option == JOptionPane.OK_OPTION) {
        new SwingWorker<List, RuntimeException>() {
            @Override/*from   w w w  . ja va2 s. co  m*/
            protected List doInBackground() throws Exception {
                try {
                    return SeHistoriaService.getInstance().createLastYearReport(params);
                } catch (RuntimeException e) {
                    publish(e);
                    return null;
                }
            }

            @Override
            protected void done() {
                try {
                    List<String> data = get();
                    if (data != null) {
                        JOptionPane.showMessageDialog(null, "Export prebehol spene");
                    }
                } catch (InterruptedException | ExecutionException ex) {
                    Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

            @Override
            protected void process(List<RuntimeException> chunks) {
                if (chunks.size() > 0) {
                    showException("Chyba", chunks.get(0));
                }
            }

        }.execute();
    }
}

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

private void jbtCheckInActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jbtCheckInActionPerformed
    if (this.jbtCheckIn.isVisible()) {
        final int confirmation = ViewUtils.showConfirmDialog(this, ViewUtils.MSG_SAVE_QUESTION,
                ViewUtils.TITLE_SAVED);/* www. ja  v  a 2  s .  co  m*/
        if (confirmation == JOptionPane.OK_OPTION) {
            final RoomStatus roomStatusCheckIn = roomStatusController.selectDisabled();
            this.invoice.setUpdated(new Date());
            this.invoice.setRoomStatus(roomStatusCheckIn);
            this.invoiceController.save(invoice);
            ViewUtils.showMessage(this, ViewUtils.MSG_SAVED, ViewUtils.TITLE_SAVED,
                    JOptionPane.INFORMATION_MESSAGE);
            this.parent.refreshRoomData();
            this.setVisible(false);
        }
    }
}

From source file:com.josescalia.tumblr.form.TumblrRssFavList.java

private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteActionPerformed
    if (JOptionPane.showConfirmDialog(this, "Are you sure to delete this data ? ") == JOptionPane.OK_OPTION) {
        try {//from   w  ww.ja v  a 2 s.c o m
            if (service.delete(selectedItem.getId())) {
                JOptionPane.showMessageDialog(this, "Delete Succeed");
            } else {
                JOptionPane.showMessageDialog(this, "Delete Failed");
            }
        } catch (Exception e) {
            logger.error(e.getMessage());
            JOptionPane.showMessageDialog(this, "Delete Failed " + e.getMessage());
        }
        btnFindActionPerformed(evt);
        setFormBean(new Rss());
    }
}

From source file:agendapoo.View.FrmCadastroAtividade.java

private void btnCadastrarActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnCadastrarActionPerformed
{//GEN-HEADEREND:event_btnCadastrarActionPerformed
    if (!isThereEmptyFields()) {
        if (convidados.isEmpty()) {
            int i = JOptionPane.showConfirmDialog(this,
                    "Parece que voc no adicionou nenhum convidado...\nVoc deseja prosseguir?");
            switch (i) {
            case JOptionPane.OK_OPTION:
                cadastrarAtividade(loggedUser);
                break;
            }/*from  w  ww .j av a2s.c o m*/
        } else
            cadastrarAtividade(loggedUser);
    } else
        JOptionPane.showMessageDialog(this, "Por favor, preencha todos os campos!", "Campos vzios",
                JOptionPane.ERROR_MESSAGE);
}

From source file:de.cenote.jasperstarter.Report.java

private Map<String, Object> promptForParams(JRParameter[] reportParams, Map<String, Object> params,
        String reportName) throws InterruptedException {
    boolean isForPromptingOnly = false;
    boolean isUserDefinedOnly = false;
    boolean emptyOnly = false;
    switch (config.getAskFilter()) {
    case ae:/*  w ww.  j av a 2  s . c o  m*/
        emptyOnly = true;
    case a:
        isForPromptingOnly = false;
        isUserDefinedOnly = false;
        break;
    case ue:
        emptyOnly = true;
    case u:
        isUserDefinedOnly = true;
        break;
    case pe:
        emptyOnly = true;
    case p:
        isUserDefinedOnly = true;
        isForPromptingOnly = true;
        break;
    }
    Report.setLookAndFeel();
    ParameterPrompt prompt = new ParameterPrompt(null, reportParams, params, reportName, isForPromptingOnly,
            isUserDefinedOnly, emptyOnly);
    if (JOptionPane.OK_OPTION != prompt.show()) {
        throw new InterruptedException("User aborted at parameter promt!");
    }
    if (config.isVerbose()) {
        System.out.println("----------------------------");
        System.out.println("Parameter prompt:");
        for (Object key : params.keySet()) {
            System.out.println(key + " = " + params.get(key));
        }
        System.out.println("----------------------------");
    }
    return params;
}

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

private void jbtDeleteActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jbtDeleteActionPerformed
    if (this.jbtDelete.isVisible()) {
        final int confirmation = ViewUtils.showConfirmDialog(this, ViewUtils.MSG_DELETE_QUESTION,
                ViewUtils.TITLE_SAVED);//from   w  w w  .  j a  v a  2 s .com
        if (confirmation == JOptionPane.OK_OPTION) {
            final RoomStatus roomStatusEnabled = roomStatusController.selectEnabled();
            final InvoiceStatus invoiceStatusDeleted = invoiceStatusController.selectDeleted();
            this.invoice.setEnabled(false);
            this.invoice.setUpdated(new Date());
            this.invoice.setRoomStatus(roomStatusEnabled);
            this.invoice.setInvoiceStatus(invoiceStatusDeleted);
            this.invoiceController.save(invoice);
            ViewUtils.showMessage(this, ViewUtils.MSG_DELETED, ViewUtils.TITLE_SAVED,
                    JOptionPane.INFORMATION_MESSAGE);
            this.parent.refreshRoomData();
            this.setVisible(false);
        }
    }
}

From source file:com.sec.ose.osi.ui.frm.main.identification.patternmatch.JPanPatternMatchMain.java

public UEPatternMatch exportUIEntity(String projectName) {

    String currentComponentName = "";
    String newComponentName = "";
    String newLicenseName = getSelectedLicenseName();

    SelectedFilePathInfo selectedPaths = IdentifyMediator.getInstance().getSelectedFilePathInfo();
    boolean bFile = selectedPaths.isFile();
    String selectedPath = selectedPaths.getSelectedPath();

    if (bFile) {/* w  w  w. j av a  2  s. c  o  m*/
        currentComponentName = IdentificationDBManager.getComponentNameForPatternMatchFile(projectName,
                selectedPath);
    } else {
        currentComponentName = IdentificationDBManager.getComponentNameForPatternMatchResetFolder(projectName,
                selectedPath);
    }

    int status = IdentificationDBManager.getStatusForPatternMatch(projectName, selectedPath);

    if (rdbtnItsLibraryWhich.isSelected()) {
        newComponentName = "DECLARED_PROPRIETARY_LIBRARY";
    } else if (rdbtnThird.isSelected()) {
        newComponentName = "DECLARED_THIRDPARTY_LIBRARY";
    } else if (rdbtnIKnowThe.isSelected()) {

        if (status == AbstractMatchInfo.STATUS_PENDING
                && getJComboBoxLicenseForOpt3().getSelectedItem() == null) {
            JOptionPane.showOptionDialog(null, "\"License\" Field must be non-empty.", "Pending identification",
                    JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE, null, buttonOK, "OK");
            return null;
        }

        if (status == AbstractMatchInfo.STATUS_PENDING
                && LicenseAPIWrapper.getLicenseID(newLicenseName) == null) {
            JOptionPane.showOptionDialog(null,
                    "The license name (" + newLicenseName + ") does not exist in Protex Server. "
                            + "\nPlease correct the license name.",
                    "Pending identification", JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE, null, buttonOK,
                    "OK");
            return null;
        }

        if ((getSelectedComponentName()).length() > 0) {
            newComponentName = getSelectedComponentName();
        } else {
            newComponentName = (String) cbPmBindType.getSelectedItem() + "_"
                    + IdentifyMediator.getInstance().getSelectedLicenseName();
        }
    }

    if (currentComponentName == null)
        currentComponentName = "";
    if (newLicenseName == null)
        newLicenseName = "";
    UEPatternMatch xUEPatternMatch = new UEPatternMatch(currentComponentName, newComponentName, newLicenseName);
    return xUEPatternMatch;
}

From source file:Interfaz.rubiktimer.java

public void cerrar() {
    try {/*from   w  w w  .j a  va2 s  . c o m*/
        this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent w) {

                int valor = JOptionPane.showConfirmDialog(null,
                        "Esta Seguro de cerrar la aplicacion?\nNota:  Asegurese de haber guardado los tiempos obtenidos ",
                        "Cerrar Rubik Cube Timer", JOptionPane.OK_CANCEL_OPTION);
                if (valor == JOptionPane.OK_OPTION) {
                    JOptionPane.showMessageDialog(null, "Gracias por usar Rubik Cube Timer", "Gracias",
                            JOptionPane.INFORMATION_MESSAGE);
                    System.exit(0);
                } else if (valor == JOptionPane.CANCEL_OPTION) {
                    System.out.println("Cnacelar Operacion de cerrar");
                }
            }
        });
        this.setVisible(true);
    } catch (Exception e) {
        e.printStackTrace();
    }
}