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:SuitaDetails.java

public void showSuiteLib() {
    JScrollPane jScrollPane1 = new JScrollPane();
    JList jList1 = new JList();
    JPanel libraries = new JPanel();
    jScrollPane1.setViewportView(jList1);
    GroupLayout layout = new GroupLayout(libraries);
    libraries.setLayout(layout);/*  w  w w .j av  a2s  .  c o  m*/
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jScrollPane1,
            GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE));

    try {
        Object[] s = (Object[]) RunnerRepository.getRPCClient().execute("getLibrariesList",
                new Object[] { RunnerRepository.user });
        String[] libs = new String[s.length];
        for (int i = 0; i < s.length; i++) {
            libs[i] = s[i].toString();
        }
        ArrayList<Integer> ind = new ArrayList<Integer>();
        jList1.setModel(new DefaultComboBoxModel(libs));
        if (parent.getLibs() != null) {
            for (String st : parent.getLibs()) {
                for (int i = 0; i < libs.length; i++) {
                    if (libs[i].equals(st)) {
                        ind.add(new Integer(i));
                    }
                }
            }
            int[] indices = new int[ind.size()];
            for (int i = 0; i < ind.size(); i++) {
                indices[i] = ind.get(i);
            }
            jList1.setSelectedIndices(indices);
        }
    } catch (Exception e) {
        System.out.println("There was an error on calling getLibrariesList on CE");
        e.printStackTrace();
    }
    int resp = (Integer) CustomDialog.showDialog(libraries, JOptionPane.PLAIN_MESSAGE,
            JOptionPane.OK_CANCEL_OPTION, RunnerRepository.window, "Libraries", null);
    if (resp == JOptionPane.OK_OPTION) {
        Object[] val = jList1.getSelectedValues();
        String[] libs = new String[val.length];
        for (int s = 0; s < val.length; s++) {
            libs[s] = val[s].toString();
        }
        parent.setLibs(libs);
    }
}

From source file:be.ac.ua.comp.scarletnebula.gui.windows.GUI.java

public void terminateSelectedServers() {
    final Collection<Server> servers = serverList.getSelectedServers();

    if (servers.isEmpty()) {
        return;/*from   ww w .  j ava2  s  .  co m*/
    }

    final String deleteMessage = "You are about to terminate " + servers.size() + " server(s). \n"
            + "Terminating a server will permanently destroy the server. This operation cannot be undone.\n\n"
            + "Do you wish to proceed?";

    final String deleteTitle = "Terminate " + servers.size() + " server(s)";
    final String buttonString = deleteTitle;
    final int result = JOptionPane.showOptionDialog(this, deleteMessage, deleteTitle,
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null,
            Arrays.asList(buttonString, "Cancel").toArray(), "Cancel");

    if (result != JOptionPane.OK_OPTION) {
        return;
    }

    (new SwingWorkerWithThrobber<Exception, Object>(
            newThrobber("Terminating server" + ((servers.size() > 1) ? "s" : ""))) {
        @Override
        protected Exception doInBackground() throws Exception {
            for (final Server server : servers) {
                try {
                    server.terminate();
                    server.refreshUntilServerHasState(VmState.TERMINATED);
                } catch (final Exception e) {
                    return e;
                }
            }
            return null;
        }

        @Override
        public void done() {
            try {
                final Exception result = get();

                if (result != null) {
                    log.error(result);
                    error(result);
                }
            } catch (final Exception ignore) {
            }
        }
    }).execute();

}

From source file:com.polivoto.vistas.Acceso.java

private void sinConexion() {
    JOptionPane.showMessageDialog(null, "Es imposible conectarse al servidor.\nRevise la conexin.", "Error",
            JOptionPane.OK_OPTION,
            new javax.swing.ImageIcon(getClass().getResource("/com/polivoto/imagenes/alert.png")));
}

From source file:ca.canuckcoding.wosqi.FeedViewer.java

private void install() {
    int tab = jTabbedPane2.getSelectedIndex();
    ArrayList<PackageEntry> pkgList = getInstallList(selected[tab]);
    String msg = "<html><body width=\"300px\">" + MessageFormat
            .format(bundle.getString("DEPENDANCY_INSTALL_WARNING"), new Object[] { selected[tab].name }) + "\n";
    ArrayList installList = new ArrayList();
    for (int i = 0; i < pkgList.size(); i++) {
        PackageEntry curr = pkgList.get(i);
        if (!pkgMgr.isInstalled(curr)) {
            if (!curr.id.equals(selected[tab].id)) {
                msg += "\n" + curr.name;
            }/* w w w .  j a v a 2s . c  o m*/
            installList.add(curr.getDownloadUrl());
        }
    }
    if (installList.size() > 1) {
        if (JOptionPane.showConfirmDialog(rootPane, msg, bundle.getString("WARNING"),
                JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
            doInstall(tab, installList);
        }
    } else {
        doInstall(tab, installList);
    }
}

From source file:br.ufrgs.enq.jcosmo.ui.COSMOSACDialog.java

private void rebuildSigmaProfiles() {
    if (listModel.getSize() == 0) {
        if (err == true) {
            err = false;//from   w  w w .j  av a 2s.  c  o m
            return;
        }
        JOptionPane.showMessageDialog(this, "Select compounds.", "Error", JOptionPane.OK_OPTION);
        return;
    }

    int num = listModel.getSize();
    COSMOSACCompound[] c = new COSMOSACCompound[num];
    double[][] area = new double[num][];
    double[][] charge = new double[num][];
    XYSeriesCollection dataset = new XYSeriesCollection();

    for (int i = 0; i < num; i++) {
        try {
            c[i] = db.getComp((String) listModel.getElementAt(i));
        } catch (SQLException e1) {
            e1.printStackTrace();
            return;
        }
    }

    COSMOSAC cosmosac = (COSMOSAC) modelBox.getSelectedItem();
    try {
        cosmosac.setComponents(c);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(2);

    for (int i = 0; i < num; i++) {

        if (c[i] == null)
            return;

        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

        area[i] = c[i].area;
        charge[i] = c[i].charge;

        int n = charge[0].length;
        XYSeries comp = new XYSeries(c[i].name);

        // charges represent the center of the segments
        comp.add(charge[i][0], area[i][0]);
        for (int j = 1; j < n; ++j) {
            comp.add(charge[i][j] - (charge[i][j] - charge[i][j - 1]) / 2, area[i][j]);
        }

        double areaT = 0;
        double absSigmaAvg = 0;
        double sigmaAvg2 = 0;
        for (int j = 1; j < n; ++j) {
            areaT += area[i][j];
            absSigmaAvg += area[i][j] * Math.abs(charge[i][j]);
            sigmaAvg2 += area[i][j] * charge[i][j] * charge[i][j];
        }
        absSigmaAvg /= areaT;
        sigmaAvg2 /= areaT;
        comp.setKey(c[i].name + " (A=" + nf.format(areaT) + ", |sigma|=" + nf.format(absSigmaAvg * 1000)
                + ", |sigma|2=" + nf.format(sigmaAvg2 * 10000) + ")");

        dataset.addSeries(comp);
        sigmaProfilePlot.setRenderer(i, stepRenderer);
        sigmaProfilePlot.getRenderer().setSeriesStroke(i, new BasicStroke(2.5f));
    }
    sigmaProfilePlot.setDataset(dataset);

    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:strobe.spectroscopy.StrobeSpectroscopy.java

private void btnSetZeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSetZeroActionPerformed
    int result = JOptionPane.showConfirmDialog(this, OPTION_PANE_TEXT, btnSetZero.getText(),
            JOptionPane.OK_CANCEL_OPTION);

    if (result == JOptionPane.OK_OPTION) {
        //Get a noise current level and assign it to darkCurrent variable
        return;/* w w w  .  j av  a 2  s  . co  m*/
    }
}

From source file:junk.gui.HazardSpectrumApplication.java

public void init() {
    try {// w  w  w.  j a v a  2  s  .c o m

        // initialize the control pick list
        initControlList();
        //initialise the list to make selection whether to show ERF_GUIBean or ERF_RupSelectorGuiBean
        initProbOrDeterList();
        // initialize the GUI components
        jbInit();

        // initialize the various GUI beans
        initIMR_GuiBean();
        initSiteGuiBean();
        initImlProb_GuiBean();
        try {
            this.initERFSelector_GuiBean();
        } catch (RuntimeException e) {
            JOptionPane.showMessageDialog(this, "Connection to ERF failed", "Internet Connection Problem",
                    JOptionPane.OK_OPTION);
            return;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Formulario.CapturaHuella.java

private void btnConfiguracionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConfiguracionActionPerformed
    // TODO add your handling code here:
    stop();//from  w  ww . j  a v a2s  .com

    int op = JOptionPane.showConfirmDialog(this,
            "No modifique estos parametros al menos que se requiera.\n" + "Desea configurar?",
            "Desea configurar?", JOptionPane.YES_NO_OPTION);
    if (op == JOptionPane.OK_OPTION) {
        //  Ingreso in=new Ingreso(this, true);
        try {

            new Ingreso(this, true).setVisible(true);
            dispose();

        } catch (Exception ex) {
            Logger.getLogger(CapturaHuella.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

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

public void deleteAccount() throws IOException, CryptoException, TransportException, ProblemReadingDatabaseFile,
        PasswordDatabaseException {/*from  w  w w .  ja  v  a 2s  .c  o m*/

    if (getLatestVersionOfDatabase()) {
        SortedListModel listview = (SortedListModel) mainWindow.getAccountsListview().getModel();
        String selectedAccName = (String) mainWindow.getAccountsListview().getSelectedValue();

        int buttonSelected = JOptionPane.showConfirmDialog(mainWindow,
                Translator.translate("askConfirmDeleteAccount", selectedAccName),
                Translator.translate("confirmDeleteAccount"), JOptionPane.YES_NO_OPTION);
        if (buttonSelected == JOptionPane.OK_OPTION) {
            //Remove the account from the listview, accountNames arraylist & the database
            listview.removeElement(selectedAccName);
            int i = accountNames.indexOf(selectedAccName);
            accountNames.remove(i);
            database.deleteAccount(selectedAccName);
            saveDatabase();
            //[1375385] Call the filter method so that the listview is 
            //reinitialised with the remaining matching items
            filter();
        }
    }

}

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

private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
    final NajminajucejsiSpotrebiteliaParams params = new NajminajucejsiSpotrebiteliaParams();
    int option = showUniversalInputDialog(params, "10% spotrebiteov s najv?ou spotrebou");
    if (option == JOptionPane.OK_OPTION) {
        new SwingWorker<List, RuntimeException>() {
            @Override/*from  w  ww. ja v  a2 s  .co m*/
            protected List doInBackground() throws Exception {
                try {
                    return SeHistoriaService.getInstance().getNajnminajucejsiSpotrebitelia(params);
                } catch (RuntimeException e) {
                    publish(e);
                    return null;
                }
            }

            @Override
            protected void done() {
                try {
                    List data = get();
                    showJTable(NajminajucejsiSpotrebitel.class, data);
                } 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();
    }
}