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

private JPanel createIconDialogBox() {
    JButton showItButton = null;/*from  w  w  w  .j  av a  2  s .  c o  m*/

    final int numButtons = 6;
    JRadioButton[] radioButtons = new JRadioButton[numButtons];
    final ButtonGroup group = new ButtonGroup();

    final String plainCommand = "plain";
    final String infoCommand = "info";
    final String questionCommand = "question";
    final String errorCommand = "error";
    final String warningCommand = "warning";
    final String customCommand = "custom";

    radioButtons[0] = new JRadioButton("Plain (no icon)");
    radioButtons[0].setActionCommand(plainCommand);

    radioButtons[1] = new JRadioButton("Information icon");
    radioButtons[1].setActionCommand(infoCommand);

    radioButtons[2] = new JRadioButton("Question icon");
    radioButtons[2].setActionCommand(questionCommand);

    radioButtons[3] = new JRadioButton("Error icon");
    radioButtons[3].setActionCommand(errorCommand);

    radioButtons[4] = new JRadioButton("Warning icon");
    radioButtons[4].setActionCommand(warningCommand);

    radioButtons[5] = new JRadioButton("Custom icon");
    radioButtons[5].setActionCommand(customCommand);

    for (int i = 0; i < numButtons; i++) {
        group.add(radioButtons[i]);
    }
    radioButtons[0].setSelected(true);

    showItButton = new JButton("Show it!");
    showItButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String command = group.getSelection().getActionCommand();

            // no icon
            if (command == plainCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "A plain message",
                        JOptionPane.PLAIN_MESSAGE);
                // information icon
            } else if (command == infoCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.",
                        "Inane informational dialog", JOptionPane.INFORMATION_MESSAGE);

                // XXX: It doesn't make sense to make a question with
                // XXX: only one button.
                // XXX: See "Yes/No (but not in those words)" for a better solution.
                // question icon
            } else if (command == questionCommand) {
                JOptionPane.showMessageDialog(frame,
                        "You shouldn't use a message dialog " + "(like this)\n" + "for a question, OK?",
                        "Inane question", JOptionPane.QUESTION_MESSAGE);
                // error icon
            } else if (command == errorCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane error",
                        JOptionPane.ERROR_MESSAGE);
                // warning icon
            } else if (command == warningCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane warning",
                        JOptionPane.WARNING_MESSAGE);
                // custom icon
            } else if (command == customCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane custom dialog",
                        JOptionPane.INFORMATION_MESSAGE, icon);
            }
        }
    });

    return create2ColPane(iconDesc + ":", radioButtons, showItButton);
}

From source file:sentimentanalyzer.ChartController.java

public void saveWordCountsChartPNG(String name) {
    try {/*from w  ww  .j  a v a 2 s .  co  m*/
        ChartUtilities.saveChartAsPNG(new File(name + ".png"), this.wordCountsChart, 800, 600);
        JOptionPane.showMessageDialog(null,
                "File saved successfully. Can be found on root directory of execution. File: " + name + ".png",
                "Saved", JOptionPane.INFORMATION_MESSAGE);
    } catch (IOException ex) {
        System.out.println(ex.getMessage());
    }
}

From source file:au.org.ala.delta.intkey.ui.CharacterImageDialog.java

@Override
public void overlaySelected(SelectableOverlay overlay) {
    ImageOverlay imageOverlay = overlay.getImageOverlay();
    if (imageOverlay.isType(OverlayType.OLNOTES)) {
        RTFBuilder builder = new RTFBuilder();
        builder.startDocument();// www .j a  v  a2 s.  c  o m
        builder.appendText(_characters.get(_selectedCharacterIndex).getNotes());
        builder.endDocument();
        displayRTFWindow(builder.toString(), "Notes");
    } else {
        if (_valuesEditable) {
            super.overlaySelected(overlay);
        } else {
            if (imageOverlay.isType(OverlayType.OLOK) || imageOverlay.isType(OverlayType.OLCANCEL)) {
                super.overlaySelected(overlay);
            } else {
                JOptionPane.showMessageDialog(this, imageForViewingOnlyMessage, "Information",
                        JOptionPane.INFORMATION_MESSAGE);
            }
        }
    }
}

From source file:javaresturentdesktopclient.EmployeeDetailsPage.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

    ServletRequest.setServletRequest(Constant.EMPLOYEE_SERVLET);

    /*List<NameValuePair> paramList = new ArrayList<>();
            //from   w w w.  j  a va  2 s . c o  m
     paramList.add(new BasicNameValuePair(Constant.KEY_COMMAND, Constant.KEY_FIND_ID));
            
             
     String response = HttpClientUtil.postRequest(paramList);
            
     double Id_get=Double.parseDouble(response)+1;
            
     String Id1 = Double.toString(Id_get);
            
     String Id;
     Id = jTextFieldEmpId.setText(Id1);*/
    String fName = jTextFieldFirstNAme.getText();
    String lName = jTextFieldLastName.getText();
    String address = jTextFieldAddress.getText();
    String contact = jTextFieldcontact.getText();
    String national_id = jTextFieldNationalId.getText();
    String salary = jTextFieldSalary.getText();
    String employeeId = jTextFieldEmpId.getText();

    //i think contact no, national id  integer
    List<NameValuePair> paramLis = new ArrayList<>();
    ServletRequest.setServletRequest(Constant.EMPLOYEE_SERVLET);
    paramLis.add(new BasicNameValuePair(Constant.KEY_COMMAND, Constant.KEY_ADD_EMPLOYEE));
    paramLis.add(new BasicNameValuePair(Constant.KEY_EMPLOYEE_ID, employeeId));
    paramLis.add(new BasicNameValuePair(Constant.KEY_FNAME, fName));
    paramLis.add(new BasicNameValuePair(Constant.KEY_LNAME, lName));
    paramLis.add(new BasicNameValuePair(Constant.KEY_ADDRESS, address));
    paramLis.add(new BasicNameValuePair(Constant.KEY_CONTACT, contact));
    paramLis.add(new BasicNameValuePair(Constant.KEY_NATIONAL_ID, national_id));
    paramLis.add(new BasicNameValuePair(Constant.KEY_POSITION, position));
    paramLis.add(new BasicNameValuePair(Constant.KEY_SALARY, salary));

    String response = HttpClientUtil.postRequest(paramLis);

    if (response.equalsIgnoreCase("success")) {
        JOptionPane.showMessageDialog(null, "SUCCESSFULLY ADDED", "Information",
                JOptionPane.INFORMATION_MESSAGE);
        SetEmployeeId();
        jTextFieldFirstNAme.setText(null);
        jTextFieldLastName.setText(null);
        jTextFieldAddress.setText(null);
        jTextFieldcontact.setText(null);
        jTextFieldNationalId.setText(null);
        jTextFieldSalary.setText(null);
        ShowTable(position);

    } else {
        JOptionPane.showMessageDialog(null, "Failed!", "Error Message", JOptionPane.ERROR_MESSAGE);
    }

}

From source file:fi.hoski.remote.ui.Admin.java

private void menuEvent() {
    JMenu eventMenu = new JMenu();
    TextUtil.populate(eventMenu, "EVENTS");
    menuBar.add(eventMenu);//  ww w . java2s  .co  m
    JMenu addEventMenu = new JMenu();
    TextUtil.populate(addEventMenu, "ADD EVENTS");
    eventMenu.add(addEventMenu);
    JMenu editEventMenu = new JMenu();
    TextUtil.populate(editEventMenu, "EDIT EVENTS");
    eventMenu.add(editEventMenu);
    JMenu deleteEventMenu = new JMenu();
    TextUtil.populate(deleteEventMenu, "DELETE EVENTS");
    eventMenu.add(deleteEventMenu);

    int index = 0;
    for (final EventType eventType : EventType.values()) {
        // add
        JMenuItem addItem = new JMenuItem();
        TextUtil.populate(addItem, eventType.name());
        addItem.addActionListener(creators[index++]);
        addEventMenu.add(addItem);
        // edit
        ActionListener editAction = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                Event selected = chooseEvent(eventType, "EDIT SELECTED");
                if (selected != null) {
                    EventEditor editor = new EventEditor(null);
                    editor.edit(selected);
                } else {
                    JOptionPane.showMessageDialog(frame, TextUtil.getText("NO SELECTION"),
                            TextUtil.getText("MESSAGE"), JOptionPane.INFORMATION_MESSAGE);
                }
            }
        };
        editAction = createActionListener(frame, editAction);
        JMenuItem editItem = new JMenuItem();
        TextUtil.populate(editItem, eventType.name());
        editItem.addActionListener(editAction);
        editEventMenu.add(editItem);
        // delete
        ActionListener deleteAction = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                List<Event> selected = chooseEvents(eventType, "DELETE SELECTED");
                if (selected != null && selected.size() >= 1) {
                    if (JOptionPane.showConfirmDialog(panel,
                            TextUtil.getText("CONFIRM DELETE")) == JOptionPane.YES_OPTION) {
                        dss.deleteEvents(selected);
                    }
                } else {
                    JOptionPane.showMessageDialog(frame, TextUtil.getText("NO SELECTION"),
                            TextUtil.getText("MESSAGE"), JOptionPane.INFORMATION_MESSAGE);
                }
            }
        };
        deleteAction = createActionListener(frame, deleteAction);
        JMenuItem deleteItem = new JMenuItem();
        TextUtil.populate(deleteItem, eventType.name());
        deleteItem.addActionListener(deleteAction);
        deleteEventMenu.add(deleteItem);
    }
}

From source file:EscribirCorreo.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    // Codigo para subir otro archivo
    subir1Field.setText("");
    JOptionPane.showMessageDialog(null, "Selecciona otro archivo para subir", "Preparado!",
            JOptionPane.INFORMATION_MESSAGE);

}

From source file:com.compomics.cell_coord.gui.controller.load.LoadTracksController.java

/**
 * Choose the directory and load its data into a given JTree.
 *
 * @param dataTree/*from   w ww  .  j  a  va 2  s  . co m*/
 */
private void chooseDirectoryAndLoadData() {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setDialogTitle("Please select a root folder containing your files");
    // allow for directories only
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    // removing "All Files" option from FileType
    fileChooser.setAcceptAllFileFilterUsed(false);
    int returnVal = fileChooser.showOpenDialog(cellCoordController.getCellCoordFrame());
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        // the directory for the data
        directory = fileChooser.getSelectedFile();
        try {
            loadDataIntoTree();
        } catch (LoadDirectoryException ex) {
            LOG.error(ex.getMessage());
            cellCoordController.showMessage(ex.getMessage(), "wrong directory structure error",
                    JOptionPane.ERROR_MESSAGE);
        }
    } else {
        cellCoordController.showMessage("Open command cancelled by user", "", JOptionPane.INFORMATION_MESSAGE);
    }
}

From source file:de.mycrobase.jcloudapp.Main.java

public void doAbout() {
    String msg = "JCloudApp 1.1.0 (C) 2012 Christian Nicolai\n\n"
            + "Easy uploading of screenshots and files to CloudApp (tm) - cross-plattform.";
    JOptionPane.showMessageDialog(null, msg, "About", JOptionPane.INFORMATION_MESSAGE, IconNormal);
}

From source file:misc.TablePrintDemo1.java

/**
 * Print the grades table.//  w  w w. j  av  a  2  s . c  o m
 */
private void printGradesTable() {
    /* Fetch printing properties from the GUI components */

    MessageFormat header = null;

    /* if we should print a header */
    if (headerBox.isSelected()) {
        /* create a MessageFormat around the header text */
        header = new MessageFormat(headerField.getText());
    }

    MessageFormat footer = null;

    /* if we should print a footer */
    if (footerBox.isSelected()) {
        /* create a MessageFormat around the footer text */
        footer = new MessageFormat(footerField.getText());
    }

    boolean fitWidth = fitWidthBox.isSelected();
    boolean showPrintDialog = showPrintDialogBox.isSelected();
    boolean interactive = interactiveBox.isSelected();

    /* determine the print mode */
    JTable.PrintMode mode = fitWidth ? JTable.PrintMode.FIT_WIDTH : JTable.PrintMode.NORMAL;

    try {
        /* print the table */
        boolean complete = gradesTable.print(mode, header, footer, showPrintDialog, null, interactive, null);

        /* if printing completes */
        if (complete) {
            /* show a success message */
            JOptionPane.showMessageDialog(this, "Printing Complete", "Printing Result",
                    JOptionPane.INFORMATION_MESSAGE);
        } else {
            /* show a message indicating that printing was cancelled */
            JOptionPane.showMessageDialog(this, "Printing Cancelled", "Printing Result",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    } catch (PrinterException pe) {
        /* Printing failed, report to the user */
        JOptionPane.showMessageDialog(this, "Printing Failed: " + pe.getMessage(), "Printing Result",
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerFrame.java

/**
 * Export data /* ww w  . jav a  2 s .  c  o  m*/
 */
protected void export() {
    statusBar.setText(getResourceString("SchemaLocalizerFrame.EXPORTING")); //$NON-NLS-1$
    statusBar.paintImmediately(statusBar.getBounds());

    schemaLocPanel.getAllDataFromUI();

    File outDir = new File(UIRegistry.getUserHomeDir() + File.separator + "schemas"); //$NON-NLS-1$
    if (outDir.exists()) {
        if (!outDir.isDirectory()) {
            JOptionPane.showMessageDialog(this,
                    getFormattedResStr("SchemaLocalizerFrame.FILE_AT_ERR", outDir.getAbsolutePath()), //$NON-NLS-1$
                    getResourceString("SchemaLocalizerFrame.FILE_EXP"), JOptionPane.INFORMATION_MESSAGE); //$NON-NLS-1$
            return;
        }

    } else {
        if (outDir.mkdir()) {

        } else {
            JOptionPane.showMessageDialog(this,
                    getFormattedResStr("SchemaLocalizerFrame.FILE_PROBLEM", outDir.getAbsolutePath()), //$NON-NLS-1$
                    getResourceString("SchemaLocalizerFrame.FILE_EXP"), JOptionPane.INFORMATION_MESSAGE); //$NON-NLS-1$
            return;
        }
    }

    if (localizableIO.exportToDirectory(outDir)) {
        JOptionPane.showMessageDialog(this,
                getFormattedResStr("SchemaLocalizerFrame.EXPORTED_TO", outDir.getAbsolutePath()), //$NON-NLS-1$
                getResourceString("SchemaLocalizerFrame.EXPORTED"), JOptionPane.INFORMATION_MESSAGE); //$NON-NLS-1$
        statusBar.setText(getResourceString("SchemaLocalizerFrame.EXPORTED")); //$NON-NLS-1$

    } else {
        statusBar.setText(getResourceString("SchemaLocalizerFrame.EXPORTING_ERR")); //$NON-NLS-1$
    }
}