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:net.sf.firemox.DeckBuilder.java

/**
 * Invoked when an action occurs./*w  w w  .  j a v a  2 s  .c  om*/
 * 
 * @param e
 *          attached event
 */
@SuppressWarnings("unchecked")
public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();
    if ("menu_help_about".equals(command)) {
        new About(form).setVisible(true);
    } else if ("menu_db_exit".equals(command)) {
        exitForm();
    } else if ("menu_db_new".equals(command)) {
        if (!verifyModification()) {
            return;
        }
        setTitle("DeckBuilder");
        deckNameTxt.setText("");
        rightListModel.getCards().clear();
        datasets.removeAll();
        modifiedSinceSave = false;
        updateChecker();
        setAsNew();
    } else if ("menu_convert_DCK_MP".equals(command)) {
        /*
         * Convert an entire directory from a format to MP one
         */
        try {
            Converter
                    .convertDCK(MToolKit
                            .showDialogFile("Choose a directory of DCK to convert", 'o', null, FILTER_DECK,
                                    this, JFileChooser.OPEN_DIALOG, JFileChooser.DIRECTORIES_ONLY)
                            .getCanonicalPath());
        } catch (IOException e1) {
            JOptionPane.showMessageDialog(this, "Error occurred reading the specified directory",
                    "File problem", JOptionPane.ERROR_MESSAGE);
        } catch (Exception e1) {
            // cancel of user;
        }
    } else if ("menu_db_constraints".equals(command)) {
        // Show the deck constraints applied on the current TBS
        new DeckRules(this).setVisible(true);
    } else if ("menu_help_help".equals(command)) {
        /*
         * This method is invoked when user has chosen to see the help file. <br>
         * TODO documentation is not yet done for this form
         */
        JOptionPane.showMessageDialog(form, "Sorry, no documentation available for deck builder",
                "Negative yet implemented", JOptionPane.INFORMATION_MESSAGE);
    } else if ("menu_db_load".equals(command)) {
        if (verifyModification()) {
            String deckFile = MToolKit.getDeckFile(this, JFileChooser.OPEN_DIALOG);
            if (deckFile != null) {
                loadDeck(deckFile, rightListModel.getCards());
            }
        }
    } else if ("menu_db_saveas".equals(command)) {
        String deckFile = MToolKit.getDeckFile(this, JFileChooser.SAVE_DIALOG);
        if (deckFile != null) {
            MSaveDeck.saveDeck(deckFile, rightListModel.getCards(), form);
            setAsSaved();
        }
    } else if ("menu_db_save".equals(command)) {
        saveCurrentDeck();
        setAsSaved();
    } else {
        // several implemented filters
        final MListModel<MCardCompare> model = (MListModel<MCardCompare>) leftList.getModel();

        final FileInputStream dbStream = MdbLoader.resetMdb();

        final List<MCardCompare> toRemove = new ArrayList<MCardCompare>();

        if ("clear".equals(command)) {
            // Reset the color filters
            for (Component component : toolBar.getComponents()) {
                if (component instanceof JToggleButton) {
                    ((JToggleButton) component).setSelected(true);
                }
            }
        }
        model.addAll(model.removedDelegate);

        final int cardType = CardFactory.getIdCard((String) idCardComboBox.getSelectedItem());
        if (cardType != -1) {
            // "All" is not selected in card type filter
            // we remove the cards that don't have the selected card id
            for (MCardCompare cardCompare : model.delegate) {
                try {
                    final CardModel cardModel = cardCompare.getModel(dbStream);
                    if (!MCard.hasIdCard(cardModel.getIdCard(), cardType)) {
                        toRemove.add(cardCompare);
                    }
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
            model.removeAll(toRemove);
            toRemove.clear();
        }

        // property filter
        // we search for the property value, if it isn't found it's because "All"
        // is selected in the comboBox
        int property = CardFactory.getProperty((String) propertiesComboBox.getSelectedItem());

        if (property != -1) {
            // "All" is not selected in property filter
            // we remove the cards that don't have the selected property
            for (MCardCompare cardCompare : model.delegate) {
                try {
                    final CardModel cardModel = cardCompare.getModel(dbStream);
                    if (!MCard.hasProperty(cardModel.getProperties(), property)) {
                        toRemove.add(cardCompare);
                    }
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
            model.removeAll(toRemove);
            toRemove.clear();
        }

        // color filters
        for (int i = 1; i < IdCardColors.CARD_COLOR_VALUES.length + 1; i++) {
            final JToggleButton colorButton = (JToggleButton) toolBar.getComponent(i);
            if (!colorButton.isSelected()) {
                for (MCardCompare cardCompare : model.delegate) {
                    try {
                        final CardModel cardModel = cardCompare.getModel(dbStream);
                        if (i == 1) {
                            if (cardModel.getIdColor() == 0) {
                                toRemove.add(cardCompare);
                            }
                        } else if ((cardModel.getIdColor()
                                & IdCardColors.CARD_COLOR_VALUES[i - 1]) == IdCardColors.CARD_COLOR_VALUES[i
                                        - 1]) {
                            toRemove.add(cardCompare);
                        }
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                }
                model.removeAll(toRemove);
                toRemove.clear();
            }
        }
        leftList.repaint();
        if (!model.isEmpty())
            leftList.setSelectedIndex(0);
    }
}

From source file:userInterface.HospitalAdminRole.ManagePatientsJPanel.java

private void viewChatBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewChatBtnActionPerformed
    int selectedRow = vitalSignjTable.getSelectedRow();
    if (selectedRow < 0) {
        JOptionPane.showMessageDialog(this, "Please select a patient from table.", "Error",
                JOptionPane.INFORMATION_MESSAGE);
        return;/*from   ww  w.  j  a  va 2 s.c o  m*/
    }
    createChart();
}

From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java

public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equalsIgnoreCase("Rename ...")) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        QueryMasterData ndata = (QueryMasterData) node.getUserObject();
        Object inputValue = JOptionPane.showInputDialog(this, "Rename this query to: ", "Rename Query Dialog",
                JOptionPane.PLAIN_MESSAGE, null, null,
                ndata.name().substring(0, ndata.name().lastIndexOf("[") - 1));

        if (inputValue != null) {
            String newQueryName = (String) inputValue;
            String requestXml = ndata.writeRenameQueryXML(newQueryName);
            lastRequestMessage = requestXml;

            setCursor(new Cursor(Cursor.WAIT_CURSOR));

            String response = QueryListNamesClient.sendQueryRequestREST(requestXml);
            if (response.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);
                    }//from w w  w. j a  v  a  2  s.  c  o  m
                });
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                return;
            }
            lastResponseMessage = response;

            if (response != null) {
                JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();

                try {
                    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                    ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                    StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                    String status = statusType.getType();

                    if (status.equalsIgnoreCase("DONE")) {
                        ndata.name(newQueryName + " [" + ndata.userId() + "]");
                        node.setUserObject(ndata);
                        //DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();

                        jTree1.repaint();
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    } else if (e.getActionCommand().equalsIgnoreCase("Delete")) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        QueryMasterData ndata = (QueryMasterData) node.getUserObject();
        Object selectedValue = JOptionPane.showConfirmDialog(this, "Delete Query \"" + ndata.name() + "\"?",
                "Delete Query Dialog", JOptionPane.YES_NO_OPTION);
        if (selectedValue.equals(JOptionPane.YES_OPTION)) {
            System.out.println("delete " + ndata.name());
            String requestXml = ndata.writeDeleteQueryXML();
            lastRequestMessage = requestXml;
            //System.out.println(requestXml);

            setCursor(new Cursor(Cursor.WAIT_CURSOR));

            String response = QueryListNamesClient.sendQueryRequestREST(requestXml);
            if (response.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);
                    }
                });
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                return;
            }
            lastResponseMessage = response;

            if (response != null) {
                JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();

                try {
                    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                    ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                    StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                    String status = statusType.getType();

                    if (status.equalsIgnoreCase("DONE")) {
                        treeModel.removeNodeFromParent(node);

                        //jTree1.repaint();
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    } else if (e.getActionCommand().equalsIgnoreCase("Refresh All")) {
        String status = loadPreviousQueries(false);
        if (status.equalsIgnoreCase("")) {
            reset(200, false);
        } else if (status.equalsIgnoreCase("CellDown")) {
            final JPanel parent = this;
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(parent,
                            "Trouble with connection to the remote server, "
                                    + "this is often a network error, please try again",
                            "Network Error", JOptionPane.INFORMATION_MESSAGE);
                }
            });
        }
    }
}

From source file:contactsdirectory.frontend.MainJFrame.java

private void removeContact() {
    if (jListContact.getSelectedIndex() < 0) {
        JOptionPane.showMessageDialog(rootPane, localizedTexts.getString("noContactSelected"), "",
                JOptionPane.INFORMATION_MESSAGE);
        return;// w  ww  .ja  v  a 2 s.  c  om
    }

    if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(rootPane,
            localizedTexts.getString("deleteContactMsg"), "", JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE)) {
        try {
            Contact contact = (Contact) jListContact.getSelectedValue();

            jProgressBar.setIndeterminate(true);
            jProgressBar.setVisible(true);

            RemoveContactSwingWorker worker = new RemoveContactSwingWorker(contact);
            worker.execute();

            ((DefaultListModel<Contact>) jListContact.getModel()).removeElement(contact);

            jProgressBar.setVisible(false);
            jProgressBar.setIndeterminate(false);
        } catch (RuntimeException e) {
            JOptionPane.showMessageDialog(this, localizedTexts.getString("removeContactErrMsg"),
                    localizedTexts.getString("errorMsgTitle"), JOptionPane.ERROR_MESSAGE);
        }
    }
}

From source file:Interfaz.rubiktimer.java

private void guardar3x3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_guardar3x3ActionPerformed
    if (listaT3x3.primero != null) {
        GuardarDatos dat = new GuardarDatos();
        dat.guardarArchivo(listaT3x3, "3 x 3", 1);
    } else {// w  w w  .  j a v  a  2s . co  m
        JOptionPane.showMessageDialog(null, "No puede guardar en un documento una Sesion VACIA (3x3)",
                "Informacin", JOptionPane.INFORMATION_MESSAGE);
    }
}

From source file:Interfaz.rubiktimer.java

private void guardar2x2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_guardar2x2ActionPerformed
    // TODO add your handling code here:
    if (listaT2x2.primero != null) {
        GuardarDatos dat = new GuardarDatos();
        dat.guardarArchivo(listaT2x2, "2 x 2", 1);
    } else {/*ww  w. j a va 2  s. com*/
        JOptionPane.showMessageDialog(null, "No puede guardar en un documento una Sesion VACIA (2x2)",
                "Informacin", JOptionPane.INFORMATION_MESSAGE);
    }

}

From source file:com.vgi.mafscaling.OpenLoop.java

protected void loadLogFile() {
    fileChooser.setMultiSelectionEnabled(true);
    if (JFileChooser.APPROVE_OPTION != fileChooser.showOpenDialog(this))
        return;//from  w  w w .  j a v a 2  s  .co m
    boolean isPolSet = polfTable.isSet();
    File[] files = fileChooser.getSelectedFiles();
    for (File file : files) {
        BufferedReader br = null;
        ArrayDeque<String[]> buffer = new ArrayDeque<String[]>();
        try {
            br = new BufferedReader(new FileReader(file.getAbsoluteFile()));
            String line = br.readLine();
            if (line != null) {
                String[] elements = line.split("(\\s*)?,(\\s*)?", -1);
                getColumnsFilters(elements, false);

                boolean resetColumns = false;
                if (logThtlAngleColIdx >= 0 || logAfLearningColIdx >= 0 || logAfCorrectionColIdx >= 0
                        || logMafvColIdx >= 0 || logAfrColIdx >= 0 || logRpmColIdx >= 0 || logLoadColIdx >= 0
                        || logCommandedAfrCol >= 0) {
                    if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null,
                            "Would you like to reset column names or filter values?", "Columns/Filters Reset",
                            JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE))
                        resetColumns = true;
                }

                if (resetColumns || logThtlAngleColIdx < 0 || logAfLearningColIdx < 0
                        || logAfCorrectionColIdx < 0 || logMafvColIdx < 0 || logAfrColIdx < 0
                        || logRpmColIdx < 0 || logLoadColIdx < 0 || (logCommandedAfrCol < 0 && !isPolSet)) {
                    ColumnsFiltersSelection selectionWindow = new OLColumnsFiltersSelection(isPolSet);
                    if (!selectionWindow.getUserSettings(elements) || !getColumnsFilters(elements, isPolSet))
                        return;
                }

                String[] flds;
                String[] afrflds;
                boolean wotFlag = true;
                boolean foundWot = false;
                double throttle;
                double stft;
                double ltft;
                double afr;
                double rpm;
                double load;
                double mafv;
                double cmdafr = 0;
                double afrErr = 0;
                int skipRowCount = 0;
                int row = 0;
                int i = 0;
                int j = 0;
                for (; i < runTables.length; ++i) {
                    if (runTables[i].getValueAt(0, 0).toString().isEmpty())
                        break;
                }
                if (i == runTables.length)
                    return;
                setCursor(new Cursor(Cursor.WAIT_CURSOR));
                for (int k = 0; k <= afrRowOffset && line != null; ++k) {
                    line = br.readLine();
                    if (line != null)
                        buffer.addFirst(line.split(",", -1));
                }
                while (line != null && buffer.size() > afrRowOffset) {
                    afrflds = buffer.getFirst();
                    flds = buffer.removeLast();
                    line = br.readLine();
                    if (line != null)
                        buffer.addFirst(line.split(",", -1));

                    try {
                        throttle = Double.valueOf(flds[logThtlAngleColIdx]);
                        if (row == 0 && throttle < 99)
                            wotFlag = false;
                        if (throttle < wotPoint) {
                            if (wotFlag == true) {
                                wotFlag = false;
                                skipRowCount = 0;
                                j -= 1;
                                while (j > 0 && skipRowCount < skipRowsOnTransition) {
                                    runTables[i].setValueAt("", j, 0);
                                    runTables[i].setValueAt("", j, 1);
                                    runTables[i].setValueAt("", j, 2);
                                    skipRowCount += 1;
                                    j -= 1;
                                }
                                skipRowCount = 0;
                            }
                        } else {
                            if (wotFlag == false) {
                                wotFlag = true;
                                skipRowCount = 0;
                                if (foundWot) {
                                    i += 1;
                                    if (i == runTables.length)
                                        return;
                                }
                                if (row > 0)
                                    j = 0;
                            }
                            if (skipRowCount >= skipRowsOnTransition) {
                                mafv = Double.valueOf(flds[logMafvColIdx]);
                                if (minMafV <= mafv) {
                                    foundWot = true;
                                    stft = Double.valueOf(flds[logAfCorrectionColIdx]);
                                    ltft = Double.valueOf(flds[logAfLearningColIdx]);
                                    afr = Double.valueOf(afrflds[logAfrColIdx]);
                                    rpm = Double.valueOf(flds[logRpmColIdx]);
                                    load = Double.valueOf(flds[logLoadColIdx]);

                                    afr = afr / ((100.0 - (ltft + stft)) / 100.0);

                                    if (logCommandedAfrCol >= 0)
                                        cmdafr = Double.valueOf(flds[logCommandedAfrCol]);
                                    else if (isPolSet)
                                        cmdafr = Utils.calculateCommandedAfr(rpm, load, minWotEnrichment,
                                                polfTable);
                                    else {
                                        JOptionPane.showMessageDialog(null,
                                                "Please set either \"Commanded AFR\" column or \"Primary Open Loop Fueling\" table",
                                                "Error", JOptionPane.ERROR_MESSAGE);
                                        return;
                                    }

                                    afrErr = (afr - cmdafr) / cmdafr * 100.0;
                                    if (Math.abs(afrErr) <= afrErrPrct) {
                                        Utils.ensureRowCount(j + 1, runTables[i]);
                                        runTables[i].setValueAt(rpm, j, 0);
                                        runTables[i].setValueAt(mafv, j, 1);
                                        runTables[i].setValueAt(afrErr, j, 2);
                                        j += 1;
                                    }
                                }
                            }
                            skipRowCount += 1;
                        }
                    } catch (NumberFormatException e) {
                        logger.error(e);
                        JOptionPane.showMessageDialog(null,
                                "Error parsing number at " + file.getName() + " line " + (row + 1) + ": " + e,
                                "Error processing file", JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                    row += 1;
                }

                if (!foundWot) {
                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    JOptionPane.showMessageDialog(null, "Sorry, no WOT pulls were found in the log file",
                            "No WOT data", JOptionPane.INFORMATION_MESSAGE);
                }
            }
        } catch (Exception e) {
            logger.error(e);
            JOptionPane.showMessageDialog(null, e, "Error opening file", JOptionPane.ERROR_MESSAGE);
        } finally {
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    logger.error(e);
                }
            }
        }
    }
}

From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java

protected void showInfo() {
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(//from   ww w.  j  ava 2 s . c om
            new JLabel(
                    "<html>Kevin Krummenauer 2015<br><br>Icons by http://jonasraskdesign.com<br><br></html>"),
            BorderLayout.NORTH);
    JLabel link = new JLabel("Kontakt: " + EMAIL);
    link.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            openEMail();
        }

    });
    link.setCursor(new Cursor(Cursor.HAND_CURSOR));
    link.setForeground(Color.BLUE);
    panel.add(link, BorderLayout.CENTER);

    JPanel panel2 = new JPanel(new GridLayout(0, 1, 4, 4));
    {
        panel2.add(new JLabel("<html><b>Libraries and its licenses</b> (click to open)</html>"),
                BorderLayout.NORTH);

        val list = Arrays.asList(
                new TwoObjectsX<String, String>("ILIAS Downloader 2",
                        ServiceFunctions.ILIASDOWNLOADER_WEBSITE_LICENSE),
                new TwoObjectsX<String, String>("Java JDK 8",
                        "http://www.oracle.com/technetwork/java/javase/terms/license/index.html"),
                new TwoObjectsX<String, String>("Apache Commons IO und Apache Commons Codec",
                        "apache_license.txt"),
                new TwoObjectsX<String, String>("Project Lombok", "lombok_license.txt"),
                new TwoObjectsX<String, String>("KSOAP2", "ksoap2_android.txt"),
                new TwoObjectsX<String, String>("Simple XML Serialization", "apache_license.txt"));
        for (val lib : list) {
            link = new JLabel(lib.getObjectA());

            if (lib.getObjectB() != null) {
                link.addMouseListener(new MouseAdapter() {

                    @Override
                    public void mouseClicked(MouseEvent e) {
                        String s = lib.getObjectB();
                        try {
                            if (s.toLowerCase().startsWith("http")) {
                                Desktop.getDesktop().browse(new URI(s));
                            } else {
                                showLicense(s);
                            }
                        } catch (Exception e1) {
                            showError("Lizenz nicht gefunden: " + s, e1);
                        }
                    }

                });
                link.setCursor(new Cursor(Cursor.HAND_CURSOR));
                link.setForeground(Color.BLUE);
            }
            panel2.add(link);
        }
    }
    panel.add(panel2, BorderLayout.SOUTH);

    JOptionPane.showMessageDialog(mainFrame, panel, "Info " + APP_NAME, JOptionPane.INFORMATION_MESSAGE);

}

From source file:com.pianobakery.complsa.LicenseKeyGUI.java

private void activatejButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_activatejButtonActionPerformed
    /**// w  w w  .  j  a  v  a2  s .c  om
     * We use a SwingWorker here because it will connect to license server
     * for activation, and it may take 2-3 seconds.
     */
    SwingWorker<License, Void> worker = new SwingWorker<License, Void>() {
        @Override
        protected void done() {
            try {
                /**
                 * Again we get license object to a temporary object to
                 * check for ActivationStatus.
                 */
                License temporaryLicenseObject = (License) get();

                /**
                 * If it is successfully activated save on disk and update
                 * GUI fields.
                 */
                if (temporaryLicenseObject.getActivationStatus() == ActivationStatus.ACTIVATION_COMPLETED) {
                    licenseObject = temporaryLicenseObject;

                    try {
                        /**
                         * We use Apache commons-io (FileUtils class) to
                         * easily save string to file.
                         *
                         * licenseObject.getLicenseString() method returns
                         * activated license string.
                         */
                        FileUtils.writeStringToFile(new File(licenseTextFileOnDisk),
                                licenseObject.getLicenseString());
                    } catch (IOException ex) {
                        Logger.getLogger(LicenseKeyGUI.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    updateGUIFieldsWithLicenseObject();
                } else {
                    /**
                     * If activation cannot be completed, display an error
                     * message.
                     */
                    JOptionPane.showMessageDialog(null,
                            "License activation error: " + temporaryLicenseObject.getActivationStatus(),
                            "Activation Error", JOptionPane.ERROR_MESSAGE);
                }
            } catch (InterruptedException ex) {
                Logger.getLogger(LicenseKeyGUI.class.getName()).log(Level.SEVERE, null, ex);
            } catch (ExecutionException ex) {
                Logger.getLogger(LicenseKeyGUI.class.getName()).log(Level.SEVERE, null, ex);
            }

            progressjLabel.setText("");

            /**
             * Activation progress is complete, enable buttons again.
             */
            activatejButton.setEnabled(true);
            changeProductKeyjButton.setEnabled(true);
            JOptionPane.showMessageDialog(null, "Please restart to enable the license", "Restart...",
                    JOptionPane.INFORMATION_MESSAGE);
        }

        @Override
        protected License doInBackground() {
            /**
             * Since example licenses are on Online.License4J the method
             * below will activate on Online.License4J when autoActivate
             * method is called without a license server address.
             */
            return LicenseValidator.autoActivate(licenseObject);

            /**
             * If you want to test your own "Auto License Generation and
             * Activation Server" you should give its address as argument
             * like below.
             */
            //return LicenseValidator.autoActivate(licenseObject, "http://YourServer.com/algas/autoactivate");
        }
    };
    worker.execute();

    progressjLabel.setText("Activating ...");

    /**
     * It is good to disable "activate" and "change product key" buttons
     * while activation is in progress.
     */
    activatejButton.setEnabled(false);
    changeProductKeyjButton.setEnabled(false);
}

From source file:canreg.client.gui.analysis.FrequenciesByYearInternalFrame.java

@Action
public void saveTableAction() {
    LinkedList<String> filesCreated = new LinkedList<String>();
    if (!resultTable.isVisible()) {
        refresh();/*  w w  w  . j av a  2  s.  co  m*/
    }
    resultScrollPane.setVisible(false);
    Writer writer = null;
    try {
        String fileName = null;
        String pivotFileName = null;
        if (chooser == null) {
            String path = localSettings.getProperty(LocalSettings.TABLES_PATH_KEY);
            if (path == null) {
                chooser = new JFileChooser();
            } else {
                chooser = new JFileChooser(path);
            }
        }
        int returnVal = chooser.showSaveDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            try {
                localSettings.setProperty(LocalSettings.TABLES_PATH_KEY,
                        chooser.getSelectedFile().getParentFile().getCanonicalPath());
                fileName = chooser.getSelectedFile().getAbsolutePath();
                pivotFileName = fileName + "-pivot.csv";
                // we force the .csv ending to the file
                if (!(fileName.endsWith(".csv") || fileName.endsWith(".CSV"))) {
                    fileName += ".csv";
                }
            } catch (IOException ex) {
                Logger.getLogger(TableBuilderInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            // cancelled
            return;
        }
        writer = new FileWriter(fileName);
        // CSVWriter csvwriter = new CSVWriter(writer, ',');
        String[] headers = new String[resultTable.getColumnCount()];

        // Write the column names
        for (int j = 0; j < headers.length; j++) {
            headers[j] = resultTable.getColumnName(j);
        }
        CSVFormat format = CSVFormat.DEFAULT.withDelimiter(',').withHeader(headers);

        CSVPrinter csvPrinter = new CSVPrinter(writer, format);

        Object[] nextLine = new String[resultTable.getColumnCount()];

        // write the rows
        for (int i = 0; i < resultTable.getRowCount(); i++) {
            for (int j = 0; j < nextLine.length; j++) {
                nextLine[j] = resultTable.getValueAt(i, j).toString();
            }
            csvPrinter.printRecord(nextLine);
        }
        csvPrinter.flush();
        csvPrinter.close();

        // We need 3 columns to work with        
        if (headers.length == 3) {
            createPivot(pivotFileName);
            filesCreated.add(pivotFileName);
            JOptionPane.showMessageDialog(this,
                    "Table written to file: " + fileName + "\nPivot table written to:" + pivotFileName, "OK",
                    JOptionPane.INFORMATION_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(this, "Table written to file: " + fileName, "OK",
                    JOptionPane.INFORMATION_MESSAGE);
        }
        filesCreated.add(fileName);

    } catch (IOException ex) {
        JOptionPane.showMessageDialog(this, "File NOT written.\n" + ex.getLocalizedMessage(), "ERROR",
                JOptionPane.ERROR_MESSAGE);
        Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            if (writer != null) {
                writer.close();
            }
            for (String fn : filesCreated) {
                Tools.openFile(fn);
            }
        } catch (IOException ex) {
            Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
        resultScrollPane.setVisible(true);
    }
}