Example usage for javax.swing JOptionPane ERROR_MESSAGE

List of usage examples for javax.swing JOptionPane ERROR_MESSAGE

Introduction

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

Prototype

int ERROR_MESSAGE

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

Click Source Link

Document

Used for error messages.

Usage

From source file:org.cds06.speleograph.graph.ValueAxisEditor.java

/**
 * {@inheritDoc}/*from   w  w w  . j ava2s  .  c o  m*/
 */
@Override
protected void setup() {
    PanelBuilder builder = new PanelBuilder(getFormLayout(), getPanel());
    CellConstraints cc = new CellConstraints();

    Dimension d = maxModifier.getPreferredSize();
    maxModifier.setPreferredSize(new Dimension(d.width + 50, d.height));
    d = minModifier.getPreferredSize();
    minModifier.setPreferredSize(new Dimension(d.width + 50, d.height));

    {
        builder.add(new JLabel("Titre de l'axe :"));
        final JTextField axisTitleField = new JTextField();
        axisTitleField.setText(axis.getLabel());
        builder.nextColumn(2);
        builder.add(axisTitleField, cc.xyw(3, 1, 5));
        addListenerOnSuccess(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String text = axisTitleField.getText();
                if (text != null && !text.equals(""))
                    axis.setLabel(axisTitleField.getText());
            }
        });
    }

    {
        builder.nextLine(2);
        builder.add(new JLabel("Valeur min. :"));
        builder.nextColumn(2);
        builder.add(lowField);
        addListenerOnSuccess(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    Double value = Double.valueOf(lowField.getText());
                    if (isApply) {
                        axis.setLowerBound(value);
                    } else if (isCancel && oldLowValue != null)
                        axis.setLowerBound(oldLowValue);
                } catch (NumberFormatException e1) {
                    canClose = false;
                    JOptionPane.showMessageDialog(ValueAxisEditor.this.getParent(),
                            "'" + lowField.getText() + "' n'est pas un nombre", "Erreur",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        });
        builder.nextColumn(2);
        builder.add(new JLabel("+"));
        builder.nextColumn(2);
        builder.add(minModifier);
    }

    {
        builder.nextLine(2);
        builder.add(new JLabel("Valeur max. :"));
        builder.nextColumn(2);
        builder.add(maxField);
        addListenerOnSuccess(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    Double value = Double.valueOf(maxField.getText());
                    if (isApply) {
                        axis.setUpperBound(value);
                    } else if (isCancel && oldHighValue != null)
                        axis.setUpperBound(oldHighValue);
                } catch (NumberFormatException e1) {
                    canClose = false;
                    JOptionPane.showMessageDialog(ValueAxisEditor.this.getParent(),
                            "'" + maxField.getText() + "' n'est pas un nombre", "Erreur",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        });
        builder.nextColumn(2);
        builder.add(new JLabel("+"));
        builder.nextColumn(2);
        builder.add(maxModifier);
    }

    {
        builder.nextLine(2);
        builder.add(new JLabel("<HTML><strong>Sries associes  l'axe</strong></HTML>"), cc.xyw(1, 7, 3));
        String linkedSeries = "<html><ul>";
        for (Series series : Series.getInstances()) {
            if (series.getAxis().equals(axis))
                linkedSeries += "<li>" + series.toString(true) + "</li>";
        }
        linkedSeries += "</ul></html>";

        builder.add(new JLabel(linkedSeries), cc.xyw(1, 8, 3));
    }

    JPanel buttonPanel = new JPanel();
    ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(buttonPanel);
    buttonBuilder.addGlue();
    {
        buttonBuilder.addButton(new AbstractAction() {

            {
                putValue(NAME, I18nSupport.translate("cancel"));
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                isCancel = true;
                isApply = false;
                canClose = true;
                validateForm();
            }
        });
    }

    {
        buttonBuilder.addButton(new AbstractAction() {

            {
                putValue(NAME, I18nSupport.translate("apply"));
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                isCancel = false;
                isApply = true;
                canClose = false;
                validateForm();
            }
        });
    }

    {
        buttonBuilder.addButton(new AbstractAction() {

            {
                putValue(NAME, I18nSupport.translate("ok"));
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                isCancel = false;
                isApply = true;
                canClose = true;
                validateForm();
            }
        });
    }

    buttonBuilder.build();
    buttonPanel.setVisible(true);
    builder.add(buttonBuilder.getPanel(), cc.xyw(1, 10, 10));

    {
        translateSlider.setToolTipText("Translation des axes");
        translateSlider.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                int maxValue = -translateSlider.getValue();
                maxModifier.setText(String.valueOf(maxValue));
                int lowValue = -translateSlider.getValue();
                minModifier.setText(String.valueOf(lowValue));
            }
        });
        builder.add(translateSlider, cc.xywh(9, 1, 1, 8));
    }
    {
        homotSlider.setToolTipText("Homothtie sur les axes");
        homotSlider.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                int maxValue = -homotSlider.getValue();
                maxModifier.setText(String.valueOf(maxValue));
                int lowValue = homotSlider.getValue();
                minModifier.setText(String.valueOf(lowValue));
            }
        });
        builder.add(homotSlider, cc.xywh(10, 1, 1, 8));
    }

    builder.build();

    getPanel().setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    addListenerOnSuccess(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (canClose)
                setVisible(false);
        }
    });
}

From source file:com.iucosoft.eavertizare.dao.impl.FirmaDaoImpl.java

@Override
public List<Firma> findAll() {
    String query = "select * from firme";
    List<Firma> firmaList = new ArrayList<>();

    try (Connection con = dataSource.getConnection();
            PreparedStatement ps = con.prepareStatement(query);
            ResultSet rs = ps.executeQuery();) {

        while (rs.next()) {
            Configuratii configuratie = configuratiiDao.findById(rs.getInt(7));
            Firma firma = new Firma();
            firma.setId(rs.getInt(1));//from w  w  w.  j a v a2  s.co  m
            firma.setNumeFirma(rs.getString(2));
            firma.setAdresaFirma(rs.getString(3));
            firma.setDescriereFirma(rs.getString(4));
            firma.setTabelaClientiLocal(rs.getString(5));
            firma.setMesajPentruClienti(rs.getString(6));
            firma.setConfiguratii(configuratie);
            firmaList.add(firma);
        }
    } catch (SQLException e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(new JFrame(), e, "Error", JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    }
    return firmaList;
}

From source file:com.tiempometa.muestradatos.JProgramTags.java

public JProgramTags(Frame owner, boolean modal) {
    super(owner, modal);
    initComponents();//from   ww w.  j a  va  2s  .  c  o  m
    logger.debug("Adding self to tag read listeners");
    ReaderContext.addReadingListener(this);
    tagReadTable.setModel(tagTableModel);
    tagReadTable.setAutoCreateRowSorter(true);
    TableRowSorter<TableModel> sorter = new TableRowSorter<>(tagReadTable.getModel());
    sorter.setComparator(0, new BibComparator());
    tagReadTable.setRowSorter(sorter);
    List<Rfid> rfidList;
    try {
        rfidList = rfidDao.findAll();
        for (Rfid rfid : rfidList) {
            totalRfidMap.put(rfid.getRfid().toUpperCase(), rfid);
        }
        JOptionPane.showMessageDialog(this, "Se cargaron " + rfidList.size() + " tags de la base de datos",
                "Cantidad de tags disponibles", JOptionPane.INFORMATION_MESSAGE);
    } catch (SQLException e) {
        JOptionPane.showMessageDialog(this,
                "No se pudo cargar la lista de tags a programar.\n" + e.getMessage(), "Error de base de datos",
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:com.sec.ose.osi.sdk.protexsdk.discovery.report.ReportFactory.java

public static BufferedReader generateReportFromHTML(String pProjectName, ReportTemplateRequest request,
        UIResponseObserver observer) {//from  w  w  w.java2  s  . c  o m
    Report report = null;
    try {
        log.debug("Project Name : " + pProjectName);
        String projectID = ProjectAPIWrapper.getProjectID(pProjectName);

        String msgHead = " > Creating Report : " + pProjectName + "\n";
        String pMessage = " >> Generating [" + request.getTitle() + "] information from server.";
        log.debug(pMessage);
        if (observer != null) {
            observer.pushMessageWithHeader(msgHead + pMessage);
        }

        report = ProtexSDKAPIManager.getReportAPI().generateAdHocProjectReport(projectID, request,
                ReportFormat.HTML);
        log.debug(report.getFileName());
    } catch (SdkFault e) {
        ErrorCode errorCode = e.getFaultInfo().getErrorCode();
        log.error("generateReportFromHTML failed (error code) : " + errorCode);
        log.error(request.getTitle() + " failed : " + Tools.getPrintStackTraceInfoString(e));
        if (observer != null) {
            observer.setFailMessage(request.getTitle() + " failed.. ");
        }
        return null;
    } catch (Exception e) {
        log.error(request.getTitle() + " failed : " + Tools.getPrintStackTraceInfoString(e));
        if (observer != null) {
            observer.setFailMessage(request.getTitle() + " failed.. ");
        }
        String addMessage = "";
        if (request.getTitle().contains("Code Matches")) {
            addMessage = "\n\"Code Match\" information can't be trusted.";
        }
        JOptionPane.showMessageDialog(null,
                "Can't get \"" + request.getTitle() + "\" from Protex Server." + addMessage, "ERROR",
                JOptionPane.ERROR_MESSAGE);
        return null;
    }

    BufferedReader htmlReportReader = null;
    if (report != null) {
        if (report.getFileContent() != null) {
            try {
                htmlReportReader = new BufferedReader(
                        new InputStreamReader(report.getFileContent().getInputStream(), "UTF-8"));
            } catch (IOException e) {
                log.warn(e.getMessage());
                if (observer != null) {
                    observer.setFailMessage("FileIO failed");
                }
            }
        }
    }
    report = null;
    return htmlReportReader;
}

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

public JComboProjectName() {

    this.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    this.setEditable(true);
    this.setPreferredSize(new Dimension(400, 27));
    this.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            long start = System.currentTimeMillis();
            actionOnProjectSelectedonProjectComboBox();
            long end = System.currentTimeMillis();
            log.debug(//from  w  w w . j ava2s. c  o  m
                    "[JComboProjectName.addActionListener()] Project Loding TIME : " + (end - start) / 1000.0);
        }
    });

    final JTextField editor = (JTextField) this.getEditor().getEditorComponent();
    editor.addKeyListener(new KeyAdapter() {

        public void keyReleased(KeyEvent e) {

            char ch = e.getKeyChar();
            int count = 0;
            String newProjectName = editor.getText();

            if (ch != KeyEvent.VK_ENTER && ch != KeyEvent.VK_BACK_SPACE
                    && (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch))) {
                return;
            }

            if (newProjectName.length() <= 0 && ch == KeyEvent.VK_BACK_SPACE) {
                count++;
                if (count >= 2) {
                    String projectName = IdentifyMediator.getInstance().getSelectedProjectName();
                    ((JTextField) JComboProjectName.this.getEditor().getEditorComponent()).setText(projectName);
                    count = 0;
                    return;
                }
            }
            if (JComboProjectName.this.getComponentCount() > 0) {
                JComboProjectName.this.removeAllItems();
            }

            JComboProjectName.this.addItem(newProjectName);
            try {
                Collection<OSIProjectInfo> ProjectsInfo = OSIProjectInfoMgr.getInstance().getAllProjects();

                String tmpProName = null;
                boolean bAnalysis = false;
                if (newProjectName.length() > 0) {
                    for (OSIProjectInfo projectInfo : ProjectsInfo) {
                        tmpProName = projectInfo.getProjectName();
                        bAnalysis = projectInfo.isAnalyzed();
                        if (tmpProName.toLowerCase().contains(newProjectName.toLowerCase()) && bAnalysis)
                            JComboProjectName.this.addItem(tmpProName);
                    }
                    if (JComboProjectName.this.getItemCount() <= 1) {
                        JComboProjectName.this.removeAllItems();
                        JOptionPane.showOptionDialog(null, "There is no project.", "Project Filter",
                                JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE, null, buttonOK, "OK");
                    }
                } else {
                    for (OSIProjectInfo projectInfo : ProjectsInfo) {
                        if (projectInfo.isManaged() == true && projectInfo.isAnalyzed()) {
                            JComboProjectName.this.addItem(projectInfo.getProjectName());
                        }
                    }
                    JComboProjectName.this.addItem(DIVIDER_LINE);
                    for (OSIProjectInfo projectInfo : ProjectsInfo) {
                        if (projectInfo.isManaged() == false && projectInfo.isAnalyzed()) {
                            JComboProjectName.this.addItem(projectInfo.getProjectName());
                        }
                    }
                    ((JTextField) JComboProjectName.this.getEditor().getEditorComponent()).setText("");
                }
            } catch (Exception e1) {
                log.warn(e1.getMessage());
            }

            JComboProjectName.this.hidePopup();
            if (newProjectName.length() > 0)
                JComboProjectName.this.showPopup();
        }
    });

}

From source file:EditorPaneExample6.java

public EditorPaneExample6() {
    super("JEditorPane Example 6");

    pane = new JEditorPane();
    pane.setEditable(false); // Start read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;/*from   w  w  w .j  a v  a2 s.co m*/
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("File name: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);

    c.gridx = 1;
    c.gridy = 0;
    c.gridwidth = 1;
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;

    textField = new JTextField(32);
    panel.add(textField, c);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    c.gridwidth = 2;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);

    // Add a "Save" button
    saveButton = new JButton("Save");
    saveButton.setEnabled(false);
    c.gridwidth = 1;
    c.gridx = 2;
    c.gridy = 0;
    c.weightx = 0.0;
    panel.add(saveButton, c);

    getContentPane().add(panel, "South");

    // Change page based on text field
    textField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            String fileName = textField.getText().trim();
            file = new File(fileName);
            absolutePath = file.getAbsolutePath();
            String url = "file:///" + absolutePath;

            try {
                // Check if the new page and the old
                // page are the same.
                URL newURL = new URL(url);
                URL loadedURL = pane.getPage();
                if (loadedURL != null && loadedURL.sameFile(newURL)) {
                    return;
                }

                // Try to display the page
                textField.setEnabled(false); // Disable input
                textField.paintImmediately(0, 0, textField.getSize().width, textField.getSize().height);

                saveButton.setEnabled(false);
                saveButton.paintImmediately(0, 0, saveButton.getSize().width, saveButton.getSize().height);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // Busy cursor
                loadingState.setText("Loading...");
                loadingState.paintImmediately(0, 0, loadingState.getSize().width,
                        loadingState.getSize().height);
                loadedType.setText("");
                loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);
                pane.setEditable(false);
                pane.setPage(url);

                loadedType.setText(pane.getContentType());
            } catch (Exception e) {
                JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url },
                        "File Open Error", JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
                textField.setEnabled(true);
                setCursor(Cursor.getDefaultCursor());
            }
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadingState.setText("Page loaded.");

                textField.setEnabled(true); // Allow entry of new file name
                textField.requestFocus();
                setCursor(Cursor.getDefaultCursor());

                // Allow editing and saving if appropriate
                pane.setEditable(file.canWrite());
                saveButton.setEnabled(file.canWrite());
            }
        }
    });

    // Save button
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            try {
                String type = pane.getContentType();
                OutputStream os = new BufferedOutputStream(new FileOutputStream(file + ".save"));
                pane.setEditable(false);
                textField.setEnabled(false);
                saveButton.setEnabled(false);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

                Document doc = pane.getDocument();
                int length = doc.getLength();
                if (type.endsWith("/rtf")) {
                    // Saving RTF - use the OutputStream
                    try {
                        pane.getEditorKit().write(os, doc, 0, length);
                        os.close();
                    } catch (BadLocationException ex) {
                    }
                } else {
                    // Not RTF - use a Writer.
                    Writer w = new OutputStreamWriter(os);
                    pane.write(w);
                    w.close();
                }
            } catch (IOException e) {
                JOptionPane.showMessageDialog(pane,
                        new String[] { "Unable to save file", file.getAbsolutePath(), }, "File Save Error",
                        JOptionPane.ERROR_MESSAGE);

            }
            pane.setEditable(file.canWrite());
            textField.setEnabled(true);
            saveButton.setEnabled(file.canWrite());
            setCursor(Cursor.getDefaultCursor());
        }
    });
}

From source file:fr.isen.browser5.Util.UrlLoader.java

private void load(String url, Object... args) {
    String method = null, action = null;
    HashMap<String, String> params = null;
    if (args.length == 3) {
        method = (String) args[0];
        action = (String) args[1];
        params = (HashMap<String, String>) args[2];
    }//w  w w.ja v  a 2  s .c  om
    try {
        url = Str.checkProtocol(url);
        String urlParameters = "";
        if (method != null) {
            url = Str.removeLastSlash(url);
            if (action.startsWith("/")) {
                action = action.substring(1);
            }
            if (action.startsWith("http://") || action.startsWith("https://")) {
                url = action;
            } else {
                url += "/" + action;
            }

            int i = 0;
            for (Map.Entry<String, String> entry : params.entrySet()) {
                urlParameters += entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), "UTF-8");
                if (!(i++ == params.size() - 1)) {
                    urlParameters += "&";
                }
            }

            if (method.equals("GET")) {
                url += "?" + urlParameters;
            }
        } else {
            method = "GET";
        }

        System.out.println();
        System.out.println("Loading url: " + url);

        URL obj = new URL(url);
        connection = (HttpURLConnection) obj.openConnection();
        connection.setReadTimeout(10000);
        connection.addRequestProperty("Accept-Language", "en-US,en;q=0.8");
        connection.addRequestProperty("User-Agent", "Lynx/2.8.8dev.3 libwww-FM/2.14 SSL-MM/1.4.1");
        connection.setRequestMethod(method);

        if (method.equals("POST")) {
            byte[] postData = urlParameters.getBytes(Charset.forName("UTF-8"));
            connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            connection.setRequestProperty("Content-Length", "" + Integer.toString(postData.length));
            connection.setRequestProperty("Content-Language", "en-US");
            connection.setDoInput(true);
            connection.setDoOutput(true);
            try (DataOutputStream wr = new DataOutputStream(connection.getOutputStream())) {
                wr.write(postData);
            }
        }

        if (handleRedirects())
            return;

        handleConnectionResponse();
    } catch (IOException ex) {
        ex.printStackTrace();
        JOptionPane.showMessageDialog(null, ex.getMessage(), ex.getClass().getSimpleName(),
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:com.tiempometa.muestradatos.JReadTags.java

private void deleteReadButtonActionPerformed(ActionEvent e) {
    int response = JOptionPane.showConfirmDialog(this,
            "Se borrar el tag seleccionado.\nEsta operacin no se puede deshacer.\nContinuar?", "Borrar tags",
            JOptionPane.WARNING_MESSAGE);
    if (response == JOptionPane.YES_OPTION) {
        try {// w w w  .  j  a va  2  s . c o  m
            List<Rfid> rfids = tagTableModel.getData();
            for (Rfid rfid : rfids) {
                rfidDao.delete(rfid);
            }
            tagTableModel.setData(new ArrayList<Rfid>());
            tagTableModel.fireTableDataChanged();
        } catch (SQLException e1) {
            JOptionPane.showMessageDialog(this, "No se pudieron borrar todos los tags. " + e1.getMessage(),
                    "Error borrando tags", JOptionPane.ERROR_MESSAGE);
        }
    }
}

From source file:arduinoserialread.SerialRead.java

private void runApp() {

    // Register a RawDataListener to receive data from Arduino
    link.addRawDataListener(this);

    // add an action listener to the connect button
    connect.addActionListener(new ActionListener() {

        @Override/*  w  w w .j  av  a  2 s  .  c om*/
        public void actionPerformed(ActionEvent e) {
            String comPort = serialCOM.getConnectionPort();
            String baudRateS = serialCOM.getBaudRate();
            if (comPort == null || "".equals(comPort)) {
                JOptionPane.showMessageDialog(connect, "Invalid COM PORT setted.", "Error",
                        JOptionPane.ERROR_MESSAGE);
            } else if (baudRateS == null || "".equals(baudRateS)) {
                JOptionPane.showMessageDialog(connect,
                        "Invalid baud rate setted. Advice: set " + Link.DEFAULT_BAUDRATE, "Error",
                        JOptionPane.ERROR_MESSAGE);
            } else {
                try {
                    int baudRate = Integer.parseInt(baudRateS);
                    // init the connection between Arduino and PC
                    boolean connected = link.connect(comPort, baudRate);
                    if (connected) {
                        connect.setEnabled(false);
                        serialCOM.setEnabled(false);
                        disconnect.setEnabled(true);
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                    String message = ex.getMessage();
                    if (message == null || message.trim().equals("")) {
                        message = "Generic Error on connection";
                    }
                    JOptionPane.showMessageDialog(connect, message, "Error", JOptionPane.ERROR_MESSAGE);
                }
            }

        }
    });

    // add an  action  listener to disconnect button 
    disconnect.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean disconnected = link.disconnect();
            if (disconnected) {
                connect.setEnabled(true);
                serialCOM.setEnabled(true);
                disconnect.setEnabled(false);
            }
        }
    });

}

From source file:br.com.elotech.sits.config.form.ConfigForm.java

private void save() {

    Properties config = new Properties(loadConfigFile());

    config.setProperty("ISS.serviceType", "elotech");

    try {//from  w ww.  j  av a  2s. c o m

        saveFields(config);

        saveKeyAlias(config);

        config.store(new FileOutputStream(new File(CONFIG_FILE)), "Arquivo gerado pelo configurador");

        close();

    } catch (Exception e) {

        LogFactory.getLog(getClass()).error(e.getLocalizedMessage(), e);

        JOptionPane.showMessageDialog(getFrame(), e.getLocalizedMessage(), "Erro durante gravao",
                JOptionPane.CLOSED_OPTION + JOptionPane.ERROR_MESSAGE);

    }

}