Example usage for javax.swing JOptionPane INFORMATION_MESSAGE

List of usage examples for javax.swing JOptionPane INFORMATION_MESSAGE

Introduction

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

Prototype

int INFORMATION_MESSAGE

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

Click Source Link

Document

Used for information messages.

Usage

From source file:be.fedict.eid.tsl.tool.TslTool.java

@Override
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (EXIT_ACTION_COMMAND.equals(command)) {
        System.exit(0);/*  w w w .  j  a  v a2s  .c  om*/
    } else if (OPEN_ACTION_COMMAND.equals(command)) {
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setDialogTitle("Open TSL");
        int returnValue = fileChooser.showOpenDialog(this);
        if (returnValue == JFileChooser.APPROVE_OPTION) {
            displayTsl(fileChooser.getSelectedFile());
        }
    } else if (ABOUT_ACTION_COMMAND.equals(command)) {
        JOptionPane.showMessageDialog(this,
                "eID TSL Tool\n" + "Copyright (C) 2009-2013 FedICT\n" + "http://code.google.com/p/eid-tsl/",
                "About", JOptionPane.INFORMATION_MESSAGE);
    } else if (CLOSE_ACTION_COMMAND.equals(command)) {
        if (this.activeTslInternalFrame.getTrustServiceList().hasChanged()) {
            int result = JOptionPane.showConfirmDialog(this, "TSL has been changed.\n" + "Save the TSL?",
                    "Save", JOptionPane.YES_NO_CANCEL_OPTION);
            if (JOptionPane.CANCEL_OPTION == result) {
                return;
            }
            if (JOptionPane.YES_OPTION == result) {
                try {
                    this.activeTslInternalFrame.save();
                } catch (IOException e) {
                    LOG.error("IO error: " + e.getMessage(), e);
                }
            }
        }
        try {
            this.activeTslInternalFrame.setClosed(true);
        } catch (PropertyVetoException e) {
            LOG.warn("property veto error: " + e.getMessage(), e);
        }
    } else if (SIGN_ACTION_COMMAND.equals(command)) {
        LOG.debug("sign");
        TrustServiceList trustServiceList = this.activeTslInternalFrame.getTrustServiceList();
        if (trustServiceList.hasSignature()) {
            int confirmResult = JOptionPane.showConfirmDialog(this,
                    "TSL is already signed.\n" + "Resign the TSL?", "Resign", JOptionPane.OK_CANCEL_OPTION);
            if (JOptionPane.CANCEL_OPTION == confirmResult) {
                return;
            }
        }
        SignSelectPkcs11FinishablePanel pkcs11Panel = new SignSelectPkcs11FinishablePanel();
        WizardDescriptor wizardDescriptor = new WizardDescriptor(
                new WizardDescriptor.Panel[] { new SignInitFinishablePanel(), pkcs11Panel,
                        new SignSelectCertificatePanel(pkcs11Panel, trustServiceList),
                        new SignFinishFinishablePanel() });
        wizardDescriptor.setTitle("Sign TSL");
        wizardDescriptor.putProperty("WizardPanel_autoWizardStyle", Boolean.TRUE);
        DialogDisplayer dialogDisplayer = DialogDisplayer.getDefault();
        Dialog wizardDialog = dialogDisplayer.createDialog(wizardDescriptor);
        wizardDialog.setVisible(true);
    } else if (SAVE_ACTION_COMMAND.equals(command)) {
        LOG.debug("save");
        try {
            this.activeTslInternalFrame.save();
            this.saveMenuItem.setEnabled(false);
        } catch (IOException e) {
            LOG.debug("IO error: " + e.getMessage(), e);
        }
    } else if (SAVE_AS_ACTION_COMMAND.equals(command)) {
        LOG.debug("save as");
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setDialogTitle("Save As");
        int result = fileChooser.showSaveDialog(this);
        if (JFileChooser.APPROVE_OPTION == result) {
            File tslFile = fileChooser.getSelectedFile();
            if (tslFile.exists()) {
                int confirmResult = JOptionPane.showConfirmDialog(this,
                        "File already exists.\n" + tslFile.getAbsolutePath() + "\n" + "Overwrite file?",
                        "Overwrite", JOptionPane.OK_CANCEL_OPTION);
                if (JOptionPane.CANCEL_OPTION == confirmResult) {
                    return;
                }
            }
            try {
                this.activeTslInternalFrame.saveAs(tslFile);
            } catch (IOException e) {
                LOG.debug("IO error: " + e.getMessage(), e);
            }
            this.saveMenuItem.setEnabled(false);
        }
    } else if (EXPORT_ACTION_COMMAND.equals(command)) {
        LOG.debug("export");
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setDialogTitle("Export to PDF");
        int result = fileChooser.showSaveDialog(this);
        if (JFileChooser.APPROVE_OPTION == result) {
            File pdfFile = fileChooser.getSelectedFile();
            if (pdfFile.exists()) {
                int confirmResult = JOptionPane.showConfirmDialog(this,
                        "File already exists.\n" + pdfFile.getAbsolutePath() + "\n" + "Overwrite file?",
                        "Overwrite", JOptionPane.OK_CANCEL_OPTION);
                if (JOptionPane.CANCEL_OPTION == confirmResult) {
                    return;
                }
            }
            try {
                this.activeTslInternalFrame.export(pdfFile);
            } catch (IOException e) {
                LOG.debug("IO error: " + e.getMessage(), e);
            }
        }
    } else if ("TSL-BE-2010-T1".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2010, Trimester.FIRST);
        displayTsl("*TSL-BE-2010-T1.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2010-T2".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2010, Trimester.SECOND);
        displayTsl("*TSL-BE-2010-T2.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2010-T3".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2010, Trimester.THIRD);
        displayTsl("*TSL-BE-2010-T3.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2011-T1".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2011, Trimester.FIRST);
        displayTsl("*TSL-BE-2011-T1.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2011-T2".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2011, Trimester.SECOND);
        displayTsl("*TSL-BE-2011-T2.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2011-T3".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2011, Trimester.THIRD);
        displayTsl("*TSL-BE-2011-T3.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2012-T1".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2012, Trimester.FIRST);
        displayTsl("*TSL-BE-2012-T1.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2012-T2".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2012, Trimester.SECOND);
        displayTsl("*TSL-BE-2012-T2.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2012-T3".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2012, Trimester.THIRD);
        displayTsl("*TSL-BE-2012-T3.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2013-T1".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2013, Trimester.FIRST);
        displayTsl("*TSL-BE-2013-T1.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2013-T2".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2013, Trimester.SECOND);
        displayTsl("*TSL-BE-2013-T2.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2013-T3".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2013, Trimester.THIRD);
        displayTsl("*TSL-BE-2013-T3.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2014-T1".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2014, Trimester.FIRST);
        displayTsl("*TSL-BE-2014-T1.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2014-T2".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2014, Trimester.SECOND);
        displayTsl("*TSL-BE-2014-T2.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2014-T3".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2014, Trimester.THIRD);
        displayTsl("*TSL-BE-2014-T3.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2015-T1".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2015, Trimester.FIRST);
        displayTsl("*TSL-BE-2015-T1.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2015-T2".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2015, Trimester.SECOND);
        displayTsl("*TSL-BE-2015-T2.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2015-T3".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2015, Trimester.THIRD);
        displayTsl("*TSL-BE-2015-T3.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    }
}

From source file:edu.ku.brc.specify.tasks.SecurityAdminTask.java

/**
 * Enables the User to change password./*from  ww w.j  av a2s.c o  m*/
 */
public static void changePassword(final boolean isStartingEmpty) {
    final ViewBasedDisplayDialog dlg = new ViewBasedDisplayDialog((Frame) UIRegistry.getTopWindow(),
            "SystemSetup", "ChangePassword", null, getResourceString(getKey("CHG_PWD_TITLE")), "OK", null, null,
            true, MultiView.HIDE_SAVE_BTN | MultiView.DONT_ADD_ALL_ALTVIEWS | MultiView.USE_ONLY_CREATION_MODE
                    | MultiView.IS_EDITTING);
    dlg.setWhichBtns(CustomDialog.OK_BTN | CustomDialog.CANCEL_BTN);

    dlg.setFormAdjuster(new FormPane.FormPaneAdjusterIFace() {
        @Override
        public void adjustForm(final FormViewObj fvo) {
            final ValPasswordField oldPwdVTF = fvo.getCompById("1");
            final ValPasswordField newPwdVTF = fvo.getCompById("2");
            final ValPasswordField verPwdVTF = fvo.getCompById("3");
            final PasswordStrengthUI pwdStrenthUI = fvo.getCompById("4");

            if (isStartingEmpty && pwdStrenthUI != null) {
                pwdStrenthUI.setDoPainting(true);
            }

            Institution institution = AppContextMgr.getInstance().getClassObject(Institution.class);
            int minPwdLen = (int) institution.getMinimumPwdLength();
            newPwdVTF.setMinLen(minPwdLen);
            verPwdVTF.setMinLen(minPwdLen);
            pwdStrenthUI.setMinPwdLen(minPwdLen);

            DocumentAdaptor da = new DocumentAdaptor() {
                @Override
                protected void changed(final DocumentEvent e) {
                    super.changed(e);

                    // Need to invoke later so the da gets to set the enabled state last.
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {

                            String pwdStr = new String(newPwdVTF.getPassword());
                            String verStr = new String(verPwdVTF.getPassword());
                            boolean pwdOK = pwdStrenthUI.checkStrength(pwdStr) && pwdStr.equals(verStr)
                                    && newPwdVTF.getState() == UIValidatable.ErrorType.Valid;
                            dlg.getOkBtn().setEnabled(pwdOK);
                            pwdStrenthUI.repaint();
                        }
                    });
                }
            };

            oldPwdVTF.getDocument().addDocumentListener(da);
            verPwdVTF.getDocument().addDocumentListener(da);
            newPwdVTF.getDocument().addDocumentListener(da);
        }
    });

    Hashtable<String, String> valuesHash = new Hashtable<String, String>();
    dlg.setData(valuesHash);
    UIHelper.centerAndShow(dlg);

    if (!dlg.isCancelled()) {
        int pwdLen = 6;

        String oldPwd = valuesHash.get("OldPwd");
        String newPwd1 = valuesHash.get("NewPwd1");
        String newPwd2 = valuesHash.get("NewPwd2");

        if (newPwd1.equals(newPwd2)) {
            if (newPwd1.length() >= pwdLen) {
                SpecifyUser spUser = AppContextMgr.getInstance().getClassObject(SpecifyUser.class);
                //String      username  = spUser.getName();
                String spuOldPwd = spUser.getPassword();

                String newEncryptedPwd = null;
                String oldDecryptedPwd = Encryption.decrypt(spuOldPwd, oldPwd);
                if (oldDecryptedPwd != null && oldDecryptedPwd.equals(oldPwd)) {
                    newEncryptedPwd = Encryption.encrypt(newPwd2, newPwd2);
                    spUser.setPassword(newEncryptedPwd);
                    if (!DataModelObjBase.save(spUser)) {
                        UIRegistry.writeTimedSimpleGlassPaneMsg(getResourceString(getKey("PWD_ERR_SAVE")),
                                Color.RED);
                    }

                } else {
                    UIRegistry.writeTimedSimpleGlassPaneMsg(getResourceString(getKey("PWD_ERR_BAD")),
                            Color.RED);
                }

                if (newEncryptedPwd != null) {
                    Pair<String, String> masterPwd = UserAndMasterPasswordMgr.getInstance()
                            .getUserNamePasswordForDB();

                    String encryptedMasterUP = UserAndMasterPasswordMgr.encrypt(masterPwd.first,
                            masterPwd.second, newPwd2);
                    if (StringUtils.isNotEmpty(encryptedMasterUP)) {
                        AppPreferences.getLocalPrefs().put(
                                UserAndMasterPasswordMgr.getInstance().getMasterPrefPath(true),
                                encryptedMasterUP);
                        UIHelper.setTextToClipboard(encryptedMasterUP);
                        UIRegistry.showLocalizedMsg(JOptionPane.INFORMATION_MESSAGE, "INFORMATION",
                                "SPUSR_NEWPWD");

                    } else {
                        UIRegistry.writeTimedSimpleGlassPaneMsg(getResourceString(getKey("PWD_ERR_RTRV")),
                                Color.RED);
                    }

                } else {
                    UIRegistry.writeTimedSimpleGlassPaneMsg(getResourceString(getKey("PWD_ERR_BAD")),
                            Color.RED);
                }
            } else {
                UIRegistry.writeTimedSimpleGlassPaneMsg(getFormattedResStr(getKey("PWD_ERR_LEN"), pwdLen),
                        Color.RED);
            }
        } else {
            UIRegistry.writeTimedSimpleGlassPaneMsg(getResourceString(getKey("PWD_ERR_NOTSAME")), Color.RED);
        }
    }
}

From source file:net.sf.jabref.gui.journals.ManageJournalsPanel.java

public ManageJournalsPanel(final JabRefFrame frame) {
    this.frame = frame;

    personalFile.setEditable(false);/*from  ww w.  j av  a  2  s.  com*/

    ButtonGroup group = new ButtonGroup();
    group.add(newFile);
    group.add(oldFile);
    addExtPan.setLayout(new BorderLayout());
    JButton addExt = new JButton(IconTheme.JabRefIcon.ADD.getIcon());
    addExtPan.add(addExt, BorderLayout.EAST);
    addExtPan.setToolTipText(Localization.lang("Add"));
    FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:200dlu:grow, 4dlu, fill:pref",
            "pref, pref, pref, 20dlu, 20dlu, fill:200dlu, 4dlu, pref");
    FormBuilder builder = FormBuilder.create().layout(layout);

    builder.addSeparator(Localization.lang("Built-in journal list")).xyw(2, 1, 6);
    JLabel description = new JLabel(
            "<HTML>" + Localization.lang("JabRef includes a built-in list of journal abbreviations.") + "<br>"
                    + Localization.lang(
                            "You can add additional journal names by setting up a personal journal list,<br>as "
                                    + "well as linking to external journal lists.")
                    + "</HTML>");
    description.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    builder.add(description).xyw(2, 2, 6);
    JButton viewBuiltin = new JButton(Localization.lang("View"));
    builder.add(viewBuiltin).xy(7, 2);
    builder.addSeparator(Localization.lang("Personal journal list")).xyw(2, 3, 6);

    builder.add(newFile).xy(3, 4);
    builder.add(newNameTf).xy(5, 4);
    JButton browseNew = new JButton(Localization.lang("Browse"));
    builder.add(browseNew).xy(7, 4);
    builder.add(oldFile).xy(3, 5);
    builder.add(personalFile).xy(5, 5);
    JButton browseOld = new JButton(Localization.lang("Browse"));
    builder.add(browseOld).xy(7, 5);

    userPanel.setLayout(new BorderLayout());
    builder.add(userPanel).xyw(2, 6, 4);
    ButtonStackBuilder butBul = new ButtonStackBuilder();
    butBul.addButton(add);
    butBul.addButton(remove);

    butBul.addGlue();
    builder.add(butBul.getPanel()).xy(7, 6);

    builder.addSeparator(Localization.lang("External files")).xyw(2, 8, 6);
    externalFilesPanel.setLayout(new BorderLayout());

    setLayout(new BorderLayout());
    builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(builder.getPanel(), BorderLayout.NORTH);
    add(externalFilesPanel, BorderLayout.CENTER);
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    JButton ok = new JButton(Localization.lang("OK"));
    bb.addButton(ok);
    JButton cancel = new JButton(Localization.lang("Cancel"));
    bb.addButton(cancel);
    bb.addUnrelatedGap();

    JButton help = new HelpAction(HelpFile.JOURNAL_ABBREV).getHelpButton();
    bb.addButton(help);
    bb.addGlue();
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    dialog = new JDialog(frame, Localization.lang("Journal abbreviations"), false);
    dialog.getContentPane().add(this, BorderLayout.CENTER);
    dialog.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);

    // Set up panel for editing a single journal, to be used in a dialog box:
    FormLayout layout2 = new FormLayout("right:pref, 4dlu, fill:180dlu", "p, 2dlu, p");
    FormBuilder builder2 = FormBuilder.create().layout(layout2);
    builder2.add(Localization.lang("Journal name")).xy(1, 1);
    builder2.add(nameTf).xy(3, 1);
    builder2.add(Localization.lang("ISO abbreviation")).xy(1, 3);
    builder2.add(abbrTf).xy(3, 3);
    journalEditPanel = builder2.getPanel();

    viewBuiltin.addActionListener(e -> {
        JTable table = new JTable(JournalAbbreviationsUtil.getTableModel(Globals.journalAbbreviationLoader
                .getRepository(JournalAbbreviationPreferences.fromPreferences(Globals.prefs))
                .getAbbreviations()));
        JScrollPane pane = new JScrollPane(table);
        JOptionPane.showMessageDialog(null, pane, Localization.lang("Journal list preview"),
                JOptionPane.INFORMATION_MESSAGE);
    });

    browseNew.addActionListener(e -> {
        Path old = null;
        if (!newNameTf.getText().isEmpty()) {
            old = Paths.get(newNameTf.getText());
        }
        String name = FileDialogs.getNewFile(frame, old.toFile(), null, JFileChooser.SAVE_DIALOG, false);
        if (name != null) {
            newNameTf.setText(name);
            newFile.setSelected(true);
        }
    });

    browseOld.addActionListener(e -> {
        Path old = null;
        if (!personalFile.getText().isEmpty()) {
            old = Paths.get(personalFile.getText());
        }
        String name = FileDialogs.getNewFile(frame, old.toFile(), null, JFileChooser.OPEN_DIALOG, false);
        if (name != null) {
            personalFile.setText(name);
            oldFile.setSelected(true);
            oldFile.setEnabled(true);
            setupUserTable();
        }
    });

    ok.addActionListener(e -> {
        if (readyToClose()) {
            storeSettings();
            dialog.dispose();
        }
    });

    Action cancelAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    };
    cancel.addActionListener(cancelAction);

    add.addActionListener(tableModel);
    remove.addActionListener(tableModel);
    addExt.addActionListener(e -> {
        externals.add(new ExternalFileEntry());
        buildExternalsPanel();
    });

    // Key bindings:
    ActionMap am = getActionMap();
    InputMap im = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", cancelAction);

    int xSize = getPreferredSize().width;
    dialog.setSize(xSize + 10, 700);
}

From source file:metodosnumericos.VentanaMetododeNewton.java

private void butCalcularActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butCalcularActionPerformed
    if (txtFdx.getText().isEmpty() || txtIteraciones.getText().isEmpty() || txtTolerancia.getText().isEmpty()
            || txtX0.getText().isEmpty()) {
        JOptionPane.showMessageDialog(null, "Verifique que los campos no esten vacios", "Mensaje",
                JOptionPane.INFORMATION_MESSAGE);
    } else {/*from ww w  . j  a  v a 2s.  c om*/
        try {
            Graficador t = new Graficador();
            double tolerancia = Double.parseDouble(txtTolerancia.getText());
            int iteraciones = Integer.parseInt(txtIteraciones.getText());
            double xi = Double.parseDouble(txtX0.getText());
            String fdx = txtFdx.getText();

            Metodos m = new Metodos();
            JOptionPane.showMessageDialog(null, m.Newton(tolerancia, xi, iteraciones, funcion, fdx, true),
                    "Resultado", JOptionPane.INFORMATION_MESSAGE);

            GeneradorTablas g = new GeneradorTablas();

            JTable tabla = g.tablaNewton(m.getNewtonXn(), m.getNewtonFx(), m.getNewtonFdx(), m.getNewtonEa(),
                    m.getNewtonEr());

            double xs;
            //Si Xi < Xv
            if (xi < m.getNewtonXn().get(m.getNewtonXn().size() - 1).doubleValue()) {
                xs = m.getNewtonXn().get(m.getNewtonXn().size() - 1).doubleValue() + 5;
            } else {
                xs = xi;
                xi = m.getNewtonXn().get(m.getNewtonXn().size() - 1).doubleValue() - 5;
            }

            panelGrafica.removeAll();
            panelGrafica.add(t.series(funcion, xi, xs));
            panelGrafica.updateUI();

            panelTabla.removeAll();
            panelTabla.add(new JScrollPane(tabla));
            panelTabla.updateUI();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Verifique que los campos sean Numeros", "Mensaje",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    }

}

From source file:net.sf.firemox.Magic.java

/**
 * @param args//ww w  .j  a  v a 2s . c  o m
 *          the command line arguments
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    Log.init();
    Log.debug("MP v" + IdConst.VERSION + ", jre:" + System.getProperty("java.runtime.version") + ", jvm:"
            + System.getProperty("java.vm.version") + ",os:" + System.getProperty("os.name") + ", res:"
            + Toolkit.getDefaultToolkit().getScreenSize().width + "x"
            + Toolkit.getDefaultToolkit().getScreenSize().height + ", root:" + MToolKit.getRootDir());
    System.setProperty("swing.aatext", "true");
    System.setProperty(SubstanceLookAndFeel.WATERMARK_IMAGE_PROPERTY,
            MToolKit.getIconPath(Play.ZONE_NAME + "/hardwoodfloor.png"));

    final File substancelafFile = MToolKit.getFile(FILE_SUBSTANCE_PROPERTIES);
    if (substancelafFile == null) {
        Log.warn("Unable to locate '" + FILE_SUBSTANCE_PROPERTIES
                + "' file, you are using the command line with wrong configuration. See http://www.firemox.org/dev/project.html documentation");
    } else {
        System.getProperties().load(new FileInputStream(substancelafFile));
    }
    MToolKit.defaultFont = new Font("Arial", 0, 11);
    try {
        if (args.length > 0) {
            final String[] args2 = new String[args.length - 1];
            System.arraycopy(args, 1, args2, 0, args.length - 1);
            if ("-rebuild".equals(args[0])) {
                XmlConfiguration.main(args2);
            } else if ("-oracle2xml".equals(args[0])) {
                Oracle2Xml.main(args2);
            } else if ("-batch".equals(args[0])) {
                if ("-server".equals(args[1])) {
                    batchMode = BATCH_SERVER;
                } else if ("-client".equals(args[1])) {
                    batchMode = BATCH_CLIENT;
                }
            } else {
                Log.error("Unknown options '" + Arrays.toString(args)
                        + "'\nUsage : java -jar starter.jar <options>, where options are :\n"
                        + "\t-rebuild -game <tbs name> [-x] [-d] [-v] [-h] [-f] [-n]\n"
                        + "\t-oracle2xml -f <oracle file> -d <output directory> [-v] [-h]");
            }
            System.exit(0);
            return;
        }
        if (batchMode == -1 && !"Mac OS X".equals(System.getProperty("os.name"))) {
            splash = new SplashScreen(MToolKit.getIconPath("splash.jpg"), null, 2000);
        }

        // language settings
        LanguageManager.initLanguageManager(Configuration.getString("language", "auto"));
    } catch (Throwable t) {
        Log.error("START-ERROR : \n\t" + t.getMessage());
        System.exit(1);
        return;
    }
    Log.debug("MP Language : " + LanguageManager.getLanguage().getName());
    speparateAvatar = Toolkit.getDefaultToolkit().getScreenSize().height > 768;

    // verify the java version, minimal is 1.5
    if (new JavaVersion().compareTo(new JavaVersion(IdConst.MINIMAL_JRE)) == -1) {
        Log.error(LanguageManager.getString("wrongjava") + IdConst.MINIMAL_JRE);
    }

    // load look and feel settings
    lookAndFeelName = Configuration.getString("preferred", MUIManager.LF_SUBSTANCE_CLASSNAME);
    // try {
    // FileInputStream in= new FileInputStream("MAGIC.TTF");
    // MToolKit.defaultFont= Font.createFont(Font.TRUETYPE_FONT, in);
    // in.close();
    // MToolKit.defaultFont= MToolKit.defaultFont.deriveFont(Font.BOLD, 11);
    // }
    // catch (FileNotFoundException e) {
    // System.out.println("editorfont.ttf not found, using default.");
    // }
    // catch (Exception ex) {
    // ex.printStackTrace();
    // }

    // Read available L&F
    final LinkedList<Pair<String, String>> lfList = new LinkedList<Pair<String, String>>();
    try {
        BufferedReader buffReader = new BufferedReader(
                new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_THEME_SETTINGS)));
        String line;
        while ((line = buffReader.readLine()) != null) {
            line = line.trim();
            if (!line.startsWith("#")) {
                final int index = line.indexOf(';');
                if (index != -1) {
                    lfList.add(new Pair<String, String>(line.substring(0, index), line.substring(index + 1)));
                }
            }
        }
        IOUtils.closeQuietly(buffReader);
    } catch (Throwable e) {
        // no place for resolve this problem
        Log.debug("Error reading L&F properties : " + e.getMessage());
    }
    for (Pair<String, String> pair : lfList) {
        UIManager.installLookAndFeel(pair.key, pair.value);
    }

    // install L&F
    if (SkinLF.isSkinLF(lookAndFeelName)) {
        // is a SkinLF Look & Feel
        /*
         * Make sure we have a nice window decoration.
         */
        SkinLF.installSkinLF(lookAndFeelName);
    } else {
        // is Metal Look & Feel
        if (!MToolKit.isAvailableLookAndFeel(lookAndFeelName)) {
            // preferred look&feel is not available
            JOptionPane.showMessageDialog(magicForm,
                    LanguageManager.getString("preferredlfpb", lookAndFeelName),
                    LanguageManager.getString("error"), JOptionPane.INFORMATION_MESSAGE);
            setDefaultUI();
        }

        // Install the preferred
        LookAndFeel newLAF = MToolKit.geLookAndFeel(lookAndFeelName);
        frameDecorated = newLAF.getSupportsWindowDecorations();

        /*
         * Make sure we have a nice window decoration.
         */
        JFrame.setDefaultLookAndFeelDecorated(frameDecorated);
        JDialog.setDefaultLookAndFeelDecorated(frameDecorated);
        UIManager.setLookAndFeel(MToolKit.geLookAndFeel(lookAndFeelName));
    }

    // Start main thread
    try {
        new Magic();
        SwingUtilities.invokeLater(SkinLF.REFRESH_RUNNER);
    } catch (Throwable e) {
        Log.fatal("In main thread, occurred exception : ", e);
        ConnectionManager.closeConnexions();
        return;
    }
}

From source file:fll.subjective.SubjectiveFrame.java

/**
 * Create a window to edit subjective scores.
 *//*from   w w w  . jav a2s  .co  m*/
public SubjectiveFrame() {
    super("Subjective Score Entry");
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    getContentPane().setLayout(new BorderLayout());

    final JPanel topPanel = new JPanel();
    getContentPane().add(topPanel, BorderLayout.NORTH);

    final JButton quitButton = new JButton("Quit");
    topPanel.add(quitButton);
    quitButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent ae) {
            quit();
        }
    });

    final JButton saveButton = new JButton("Save");
    topPanel.add(saveButton);
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent ae) {
            try {
                save();
            } catch (final IOException ioe) {
                JOptionPane.showMessageDialog(null, "Error writing to data file: " + ioe.getMessage(), "Error",
                        JOptionPane.ERROR_MESSAGE);
            }

        }
    });

    final JButton summaryButton = new JButton("Summary");
    topPanel.add(summaryButton);
    summaryButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent ae) {
            final SummaryDialog dialog = new SummaryDialog(SubjectiveFrame.this);

            dialog.pack();
            dialog.setVisible(true);
        }
    });

    final JButton compareButton = new JButton("Compare Scores");
    topPanel.add(compareButton);
    compareButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent ae) {
            final File compareFile = chooseSubjectiveFile("Choose the file to compare with");
            if (null != compareFile) {
                try {
                    save();
                } catch (final IOException ioe) {
                    JOptionPane.showMessageDialog(null, "Error writing to data file: " + ioe.getMessage(),
                            "Error", JOptionPane.ERROR_MESSAGE);
                }

                try {
                    final Collection<SubjectiveScoreDifference> diffs = SubjectiveUtils
                            .compareSubjectiveFiles(getFile(), compareFile);
                    if (null == diffs) {
                        JOptionPane.showMessageDialog(null,
                                "Challenge descriptors are different, comparison failed", "Error",
                                JOptionPane.ERROR_MESSAGE);

                    } else if (!diffs.isEmpty()) {
                        showDifferencesDialog(diffs);
                    } else {
                        JOptionPane.showMessageDialog(null, "No differences found", "No Differences",
                                JOptionPane.INFORMATION_MESSAGE);

                    }
                } catch (final SAXParseException spe) {
                    final String errorMessage = String.format(
                            "Error parsing file line: %d column: %d%n Message: %s%n This may be caused by using the wrong version of the software attempting to parse a file that is not subjective data.",
                            spe.getLineNumber(), spe.getColumnNumber(), spe.getMessage());
                    LOGGER.error(errorMessage, spe);
                    JOptionPane.showMessageDialog(null, errorMessage, "Error", JOptionPane.ERROR_MESSAGE);
                } catch (final SAXException se) {
                    final String errorMessage = "The subjective scores file was found to be invalid, check that you are parsing a subjective scores file and not something else";
                    LOGGER.error(errorMessage, se);
                    JOptionPane.showMessageDialog(null, errorMessage, "Error", JOptionPane.ERROR_MESSAGE);
                } catch (final IOException e) {
                    LOGGER.error("Error reading compare file", e);
                    JOptionPane.showMessageDialog(null, "Error reading compare file: " + e.getMessage(),
                            "Error", JOptionPane.ERROR_MESSAGE);

                }
            }
        }
    });

    tabbedPane = new JTabbedPane();
    getContentPane().add(tabbedPane, BorderLayout.CENTER);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(final WindowEvent e) {
            quit();
        }
    });

    pack();
}

From source file:com.smanempat.controller.ControllerClassification.java

public String[] processMining(JTextField textNumberOfK, JTable tablePreview, JLabel labelPesanError,
        JTable tableResult, JLabel labelSiswaIPA, JLabel labelSiswaIPS, JLabel labelKeterangan,
        JYearChooser jYearChooser1, JYearChooser jYearChooser2, JTabbedPane jTabbedPane1) {

    String numberValidate = textNumberOfK.getText();
    ModelClassification modelClassification = new ModelClassification();
    int rowCountModel = modelClassification.getRowCount();
    int rowCountData = tablePreview.getRowCount();
    System.out.println("Row Count Data : " + rowCountData);
    System.out.println("Row Count Model : " + rowCountModel);
    String[] knnValue = null;/*from  w  ww  .java2  s .c o  m*/

    /*Validasi Nilai Number of Nearest Neighbor*/
    if (Pattern.matches("[0-9]+", numberValidate) == false && numberValidate.length() > 0) {
        labelPesanError.setText("Number of Nearest Neighbor tidak valid");
        JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak valid!", "Error",
                JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png"));
        textNumberOfK.requestFocus();
    } else if (numberValidate.isEmpty()) {
        JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak boleh kosong!", "Error",
                JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png"));
        labelPesanError.setText("Number of Nearest Neighbor tidak boleh kosong");
        textNumberOfK.requestFocus();
    } else if (Integer.parseInt(numberValidate) >= rowCountModel) {
        labelPesanError.setText("Number of Nearest Neighbor tidak boleh lebih dari " + rowCountModel + "");
        JOptionPane.showMessageDialog(null,
                "Number of Nearest Neighbor tidak boleh lebih dari " + rowCountModel + " !", "Error",
                JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png"));
        textNumberOfK.requestFocus();
    } else {
        int confirm = 0;
        confirm = JOptionPane.showOptionDialog(null, "Yakin ingin memproses data?", "Proses Klasifikasi",
                JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
        if (confirm == JOptionPane.OK_OPTION) {
            int kValue = Integer.parseInt(textNumberOfK.getText());
            String[][] modelValue = getModelValue(rowCountModel);
            double[][] dataValue = getDataValue(rowCountData, tablePreview);
            knnValue = getKNNValue(rowCountData, rowCountModel, modelValue, dataValue, kValue);
            showClassificationResult(tableResult, tablePreview, knnValue, rowCountData, labelSiswaIPA,
                    labelSiswaIPS, labelKeterangan, jYearChooser1, jYearChooser2, kValue);
            jTabbedPane1.setSelectedIndex(1);
        }

    }
    return knnValue;
}

From source file:net.sf.keystore_explorer.gui.CreateApplicationGui.java

private void upgradeCryptoStrength() {
    closeSplash();/*from   w w w .  j a v a 2 s . c  o  m*/

    JOptionPane.showMessageDialog(new JFrame(), res.getString("CryptoStrengthUpgrade.UpgradeRequired.message"),
            KSE.getApplicationName(), JOptionPane.INFORMATION_MESSAGE);

    DUpgradeCryptoStrength dUpgradeCryptoStrength = new DUpgradeCryptoStrength(new JFrame());
    dUpgradeCryptoStrength.setLocationRelativeTo(null);
    dUpgradeCryptoStrength.setVisible(true);

    if (dUpgradeCryptoStrength.hasCryptoStrengthBeenUpgraded()) {
        // Crypto strength upgraded - restart required to take effect
        JOptionPane.showMessageDialog(new JFrame(), res.getString("CryptoStrengthUpgrade.Upgraded.message"),
                KSE.getApplicationName(), JOptionPane.INFORMATION_MESSAGE);

        KseRestart.restart();
        System.exit(0);
    } else if (dUpgradeCryptoStrength.hasCryptoStrengthUpgradeFailed()) {
        // Manual install instructions have already been displayed
        System.exit(1);
    } else {
        // Crypto strength not upgraded - exit as upgrade required
        JOptionPane.showMessageDialog(new JFrame(), res.getString("CryptoStrengthUpgrade.NotUpgraded.message"),
                KSE.getApplicationName(), JOptionPane.WARNING_MESSAGE);

        System.exit(1);
    }
}

From source file:com.frostwire.gui.library.Device.java

public void upload(File[] files) {
    try {//from w  w w  .j  ava 2  s .  c o  m
        final DesktopUploadRequest dur = new DesktopUploadRequest();

        dur.address = NetworkUtils.getLocalAddress().getHostAddress();
        dur.computerName = NetworkUtils.getLocalAddress().getHostName();
        dur.files = new ArrayList<FileDescriptor>();

        for (File f : flatFiles(files)) {
            for (File cf : getFiles(f, 3)) {
                FileDescriptor fd = new FileDescriptor();
                fd.filePath = cf.getAbsolutePath();
                fd.fileSize = cf.length();

                dur.files.add(fd);
            }
        }

        HttpFetcher fetcher = new HttpFetcher(
                "http://" + _address.getHostAddress() + ":" + _port + "/dekstop-upload-request", 60000);

        String json = new JsonEngine().toJson(dur);

        final DeviceUploadDialog dlg = new DeviceUploadDialog(GUIMediator.getAppFrame());

        fetcher.asyncPostJSON(json, new HttpFetcherListener() {

            @Override
            public void onSuccess(final byte[] body) {
                GUIMediator.safeInvokeAndWait(new Runnable() {
                    @Override
                    public void run() {
                        if (dlg.isVisible()) {
                            dlg.setVisible(false);
                            try {
                                String token = new String(body, "UTF-8");

                                executor.execute(new DeviceUploadTask(Device.this,
                                        dur.files.toArray(new FileDescriptor[0]), token));
                            } catch (Throwable e) {
                                LOG.error("Error uploading files to device", e);
                            }
                        }
                    }
                });
            }

            @Override
            public void onError(Throwable e) {
                GUIMediator.safeInvokeLater(new Runnable() {
                    @Override
                    public void run() {
                        if (dlg.isVisible()) {
                            dlg.setVisible(false);
                            JOptionPane.showMessageDialog(GUIMediator.getAppFrame(), I18n.tr(
                                    "The device is busy with another transfer or did not authorize your request"),
                                    I18n.tr("Transfer failed"), JOptionPane.INFORMATION_MESSAGE);
                        }
                    }
                });
            }
        });

        dlg.setVisible(true);

    } catch (Throwable e) {
        LOG.error("Error uploading files to device", e);
    }
}

From source file:edu.harvard.i2b2.patientMapping.serviceClient.IMQueryClient.java

public static String sendGetAuditQueryRequestREST(String XMLstr) {
    try {/*w w w.j  a  v  a 2  s  . c om*/
        SAXBuilder parser = new SAXBuilder();
        String xmlContent = XMLstr;
        java.io.StringReader xmlStringReader = new java.io.StringReader(xmlContent);
        org.jdom.Document tableDoc = parser.build(xmlStringReader);
        XMLOutputter o = new XMLOutputter();
        o.setFormat(Format.getPrettyFormat());
        StringWriter str = new StringWriter();
        o.output(tableDoc, str);

        MessageUtil.getInstance().setRequest("URL: " + getAuditServiceName() + "\n" + str);//XMLstr);

        OMElement payload = getQueryPayLoad(XMLstr);
        Options options = new Options();

        targetEPR = new EndpointReference(getAuditServiceName());
        options.setTo(targetEPR);

        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
        options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);
        options.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(600000));
        options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new Integer(600000));

        ServiceClient sender = new ServiceClient();
        sender.setOptions(options);

        OMElement responseElement = sender.sendReceive(payload);
        MessageUtil.getInstance()
                .setResponse("URL: " + getAuditServiceName() + "\n" + responseElement.toString());

        return responseElement.toString();
    } catch (AxisFault axisFault) {
        axisFault.printStackTrace();
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                JOptionPane.showMessageDialog(null,
                        "Trouble with connection to the remote server, "
                                + "this is often a network error, please try again",
                        "Network Error", JOptionPane.INFORMATION_MESSAGE);
            }
        });

        return null;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}