Example usage for javax.swing JOptionPane WARNING_MESSAGE

List of usage examples for javax.swing JOptionPane WARNING_MESSAGE

Introduction

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

Prototype

int WARNING_MESSAGE

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

Click Source Link

Document

Used for warning messages.

Usage

From source file:com.genericworkflownodes.knime.nodes.io.OutputFileNodeDialog.java

/**
 * New pane for configuring MimeFileExporter node dialog.
 *///from  w w w.ja  va2 s .c  o m
public OutputFileNodeDialog(final String settingsName) {
    this.settingsName = settingsName;
    dialogPanel = new JPanel();
    componentContainer = new JPanel();
    textField = new JTextField();
    textField.setPreferredSize(new Dimension(300, textField.getPreferredSize().height));
    searchButton = new JButton("Browse");
    searchButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            final JFileChooser jfc = new JFileChooser();
            if (!"".equals(textField.getText().trim())
                    && new File(textField.getText().trim()).getParent() != null) {
                jfc.setCurrentDirectory(new File(textField.getText().trim()).getParentFile());
            }

            jfc.setAcceptAllFileFilterUsed(false);
            jfc.setFileFilter(extensionFilter);

            // int returnVal = jfc.showSaveDialog(dialogPanel);
            jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int returnVal = jfc.showDialog(dialogPanel, "Select output file");
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                // validate extension
                if (!extensionFilter.accept(jfc.getSelectedFile())) {
                    String message = "The selected output file has an invalid file extension.\n";
                    if (extensionFilter.getExtensions().length == 1) {
                        message += "Please choose a file with extension: " + extensionFilter.getExtensions()[0];
                    } else {
                        message += "Please choose a file with on of the following extensions: ";
                        message += StringUtils.join(extensionFilter.getExtensions(), ", ");
                    }
                    JOptionPane.showMessageDialog(getPanel(), message, "Selected Output File is invalid.",
                            JOptionPane.WARNING_MESSAGE);
                }
                textField.setText(jfc.getSelectedFile().getAbsolutePath());
            }
        }
    });
    setLayout();
    addComponents();

    addTab("Choose File", dialogPanel);
}

From source file:UserInterface.SearchPatientJPanel.java

private void btnGenerateChartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGenerateChartActionPerformed
    int row = patientTable.getSelectedRow();
    if (row < 0) {
        JOptionPane.showMessageDialog(null, "Please select person", "Warning", JOptionPane.WARNING_MESSAGE);
    } else {/*from   w  w w  . j ava  2 s .  co m*/
        Patient patient = (Patient) patientTable.getValueAt(row, 0);
        for (VitalSign vs : patient.getVitalSignHistory().getVitalSignList()) {
            DefaultCategoryDataset dataset = new DefaultCategoryDataset();
            JPanel chartJPanel = new JPanel();
            dataset.setValue(vs.getRespiratoryRate(), "RR", "Respiratory Rate");
            dataset.setValue(vs.getHeartRate(), "HR", "Heart Rate");
            dataset.setValue(vs.getBloodPressure(), "BP", "BP");
            dataset.setValue(vs.getWeight(), "WT", "Weight");
            JFreeChart chart = ChartFactory.createBarChart("Vital Sign", "Vital Sign", "Values", dataset);
            ChartFrame frame = new ChartFrame("Bar chart for Vital Sign", chart);
            ChartPanel chartPanel = new ChartPanel(chart);
            chartPanel.setDomainZoomable(true);
            chartJPanel.setLayout(new BorderLayout());
            chartJPanel.add(chartPanel, BorderLayout.NORTH);
            frame.setVisible(true);
            frame.setSize(500, 300);

        }
    }

    // TODO add your handling code here:
}

From source file:by.dak.cutting.permision.PermissionManager.java

public boolean checkPermission(Object o, boolean showDenyMessage) {
    String message = resourceMap.getString("permission.message.deny");
    String title = resourceMap.getString("permission.title.deny");

    boolean deny = false;
    if (FacadeContext.getEmployee() != null) {
        String department = FacadeContext.getEmployee().getDepartment().getName();
        try {/*from  w w  w .j  a v a  2  s. c  om*/
            Role role = Role.valueOf(department);
            String permissions = resourceMap.getString("permission." + role.name() + ".deny");
            List<String> lPermissions = Arrays.asList(StringUtils.split(permissions, ','));
            String s;
            if (o instanceof String)
                s = (String) o;
            else
                s = o.getClass().getSimpleName();

            deny = lPermissions.contains(s);
            if (!deny && o instanceof Component) {
                deny = lPermissions.contains(((Component) o).getName());
            }
        } catch (Exception e) {
            deny = true;
            //e.printStackTrace();
        }
        if (deny && showDenyMessage) {
            JOptionPane.showMessageDialog(CuttingApp.getApplication().getMainFrame(), message, title,
                    JOptionPane.WARNING_MESSAGE);
        }
    }
    return !deny;
}

From source file:gda.gui.beans.SimpleBinaryBean.java

protected boolean executeCommand() {
    if (hasConfirmationDialog) {
        int dialogSelection = JOptionPane.showConfirmDialog(SimpleBinaryBean.this, dialogMessage, dialogTitle,
                JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
        if (dialogSelection == JOptionPane.NO_OPTION)
            return false;
    }//from   w  ww.j  av a  2  s  . c  o  m
    return true;
}

From source file:org.pgptool.gui.ui.encrypttext.EncryptTextPm.java

private void notifyUserOfMissingKeysIfAny(Set<String> missedKeys) {
    if (CollectionUtils.isEmpty(missedKeys)) {
        return;/*from www  . jav  a  2s  .  co  m*/
    }

    UiUtils.messageBox(findRegisteredWindowIfAny(),
            text("error.notAllRecipientsAvailable", Arrays.asList(missedKeys)), text("term.attention"),
            JOptionPane.WARNING_MESSAGE);
}

From source file:UndoDemo.java

void warn(String msg) {
    JOptionPane.showMessageDialog(this, "Warning: " + msg, "Warning", JOptionPane.WARNING_MESSAGE);
}

From source file:io.github.jeremgamer.editor.panels.Buttons.java

public Buttons(final JFrame frame, final ButtonPanel be, final PanelSave ps) {
    this.setBorder(BorderFactory.createTitledBorder(""));

    this.frame = frame;

    JButton add = null;/*from w  w w .  j a  v  a 2  s  .co m*/
    try {
        add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    add.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                JOptionPane jop = new JOptionPane();
                @SuppressWarnings("static-access")
                String name = jop.showInputDialog(null, "Nommez le bouton :", "Crer un bouton",
                        JOptionPane.QUESTION_MESSAGE);

                if (name != null) {
                    for (int i = 0; i < data.getSize(); i++) {
                        if (data.get(i).equals(name)) {
                            name += "1";
                        }
                    }
                    data.addElement(name);
                    new ButtonSave(name);
                    ActionPanel.updateLists();
                    OtherPanel.updateLists();
                    PanelsPanel.updateLists();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

        }

    });

    JButton remove = null;
    try {
        remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    remove.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                if (buttonList.getSelectedValue() != null) {
                    File file = new File("projects/" + Editor.getProjectName() + "/buttons/"
                            + buttonList.getSelectedValue() + "/" + buttonList.getSelectedValue() + ".rbd");
                    JOptionPane jop = new JOptionPane();
                    @SuppressWarnings("static-access")
                    int option = jop.showConfirmDialog(null, "tes-vous sr de vouloir supprimer ce bouton?",
                            "Avertissement", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);

                    if (option == JOptionPane.OK_OPTION) {
                        File dir = new File("projects/" + Editor.getProjectName() + "/panels");
                        for (File f : FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE,
                                TrueFileFilter.INSTANCE)) {
                            if (!f.isDirectory()) {
                                try {
                                    ps.load(f);
                                } catch (IOException e) {
                                    e.printStackTrace();
                                }
                                for (String section : ps
                                        .getSectionsContaining(buttonList.getSelectedValue() + " (Bouton)")) {
                                    ps.removeSection(section);
                                    try {
                                        ps.save(f);
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                        if (buttonList.getSelectedValue().equals(be.getFileName())) {
                            be.setFileName("");
                        }
                        be.hide();
                        file.delete();
                        File parent = new File(file.getParent());
                        for (File img : FileUtils.listFiles(parent, TrueFileFilter.INSTANCE,
                                TrueFileFilter.INSTANCE)) {
                            img.delete();
                        }
                        parent.delete();
                        data.remove(buttonList.getSelectedIndex());
                        ActionPanel.updateLists();
                        OtherPanel.updateLists();
                        PanelsPanel.updateLists();
                    }
                }
            } catch (NullPointerException npe) {
                npe.printStackTrace();
            }

        }

    });

    JPanel buttons = new JPanel();
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS));
    buttons.add(add);
    buttons.add(remove);

    updateList();
    buttonList.addMouseListener(new MouseAdapter() {
        @SuppressWarnings("unchecked")
        public void mouseClicked(MouseEvent evt) {
            JList<String> list = (JList<String>) evt.getSource();
            if (evt.getClickCount() == 2) {
                int index = list.locationToIndex(evt.getPoint());
                if (isOpen == false) {
                    be.load(new File("projects/" + Editor.getProjectName() + "/buttons/"
                            + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index)
                            + ".rbd"));
                    be.show();
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            be.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            be.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            be.load(new File("projects/" + Editor.getProjectName() + "/buttons/"
                                    + list.getModel().getElementAt(index) + "/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        be.hide();
                        list.clearSelection();
                    }
                }
            } else if (evt.getClickCount() == 3) {
                int index = list.locationToIndex(evt.getPoint());
                if (isOpen == false) {
                    be.load(new File("projects/" + Editor.getProjectName() + "/buttons/"
                            + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index)
                            + ".rbd"));
                    be.show();
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            be.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            be.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            be.load(new File("projects/" + Editor.getProjectName() + "/buttons/"
                                    + list.getModel().getElementAt(index) + "/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        be.hide();
                        list.clearSelection();
                    }
                }
            }
        }
    });
    JScrollPane listPane = new JScrollPane(buttonList);
    listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED);
    this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    this.add(buttons);
    this.add(listPane);

}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDRResultsController.java

/**
 * Create the PDF report file.//from w  w w .j  a  v a 2 s. c  om
 *
 * @param directory
 * @param reportName
 * @return the file created
 */
@Override
public File createAnalysisReport(File directory, String reportName) {
    this.experiment = doseResponseController.getExperiment();
    File pdfFile = new File(directory, reportName);
    if (reportName.endsWith(".pdf")) {
        tryToCreateFile(pdfFile);
    } else {
        doseResponseController.showMessage("Please use .pdf extension for the file.", "extension file problem",
                JOptionPane.WARNING_MESSAGE);
        // retry to create pdf file
        try {
            doseResponseController.createPdfReport();
        } catch (IOException ex) {
            LOG.error(ex.getMessage(), ex);
            doseResponseController.showMessage("An error occurred: " + ex.getMessage(), "unexpected error",
                    JOptionPane.ERROR_MESSAGE);
        }
    }
    return pdfFile;
}

From source file:org.adamkrajcik.gui.MainForm.java

public MainForm() {

    DataSource bds = new EmbeddedDatabaseBuilder().setType(DERBY).addScript("classpath:createTables.sql")
            .addScript("classpath:testData.sql").build();
    dataSource = bds;//from   w  w  w  .  j av a 2  s . c  o m

    /*config = ResourceBundle.getBundle("org/adamkrajcik/gui/resources/config");
            
     BasicDataSource bds = new BasicDataSource();
     bds.setUrl(config.getString("url"));
     bds.setUsername(config.getString("user"));
     bds.setPassword(config.getString("password"));
     bds.setDriverClassName("org.apache.derby.jdbc.ClientDriver");
     dataSource = bds;
    */

    try {
        langResource = ResourceBundle.getBundle("org/adamkrajcik/gui/resources/lang", getLocale());
    } catch (Exception ex) {
        langResource = ResourceBundle.getBundle("org/adamkrajcik/gui/resources/lang");
        log.debug("Error local language bundle doesnt exist.", ex);
        JOptionPane.showMessageDialog(rootPane,
                "This application isn't yet translated to your language. Default language was set. ", "Warning",
                JOptionPane.WARNING_MESSAGE);
    }

    WineManagerImpl wmi = new WineManagerImpl();
    wmi.setDataSource(dataSource);
    wineManager = wmi;

    CellarManagerImpl cmi = new CellarManagerImpl();
    cmi.setDataSource(dataSource);
    cellarManager = cmi;

    WineCellarsManagerImpl wcmi = new WineCellarsManagerImpl();
    wcmi.setDataSource(dataSource);
    wineCellarManager = wcmi;

    wineTableModel = new WineTableModel(wineManager, wineCellarManager, langResource);
    cellarTableModel = new CellarTableModel(cellarManager, wineCellarManager, langResource);

    new LoadAllCellarsSwingWorker().execute();
    new LoadAllWinesSwingWorker().execute();

    initComponents();
    wineFilterPanel.setVisible(false);
    WineTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
}

From source file:fedroot.dacs.swingdemo.DacsSwingDemo.java

/**
 * //from w w  w  .ja va  2 s . c  o  m
 * @param title the title of the top level window
 * @param sessionManager a DACS aware session manager for login, logout, making HTTP requests, saving session state
 * @throws java.lang.Exception 
 */
public DacsSwingDemo(String title, final SessionManager sessionManager) {

    logger.log(Level.FINEST, "Launching MainFrame ");

    mainFrame = new JFrame(title);
    Dimension minSize = new Dimension(600, 400);
    mainFrame.setMinimumSize(minSize);
    mainFrame.setLocationRelativeTo(null);
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    this.sessionManager = sessionManager;

    loginDialog = new DacsLoginDialog(mainFrame, "Login", sessionManager);

    DacsEventNotifier.Listener dacsEventListener = new DacsEventNotifier.Listener() {

        @Override
        public void status(Status status) {
            // TODO replace this with updates to the status line text at the bottom of the frame
            switch (status) {
            case signon:
                btnLOGIN.setEnabled(false);
                btnLOGOUT.setEnabled(true);
                break;
            case signout:
                btnLOGIN.setEnabled(true);
                btnLOGOUT.setEnabled(false);
                break;
            }
        }

        @Override
        public void notify(DacsException ex, DacsCheckRequest checkRequest) {
            switch (ex.getStatusCode()) {
            case 900:
                JOptionPane.showMessageDialog(mainFrame, ex.getMessage(), "900 Error",
                        JOptionPane.WARNING_MESSAGE);
                break;
            case 901:
                JOptionPane.showMessageDialog(mainFrame, ex.getMessage(), "901 Error",
                        JOptionPane.WARNING_MESSAGE);
                break;
            case 902:
                //                        JOptionPane.showMessageDialog(mainFrame, ex.getMessage(), "902 Error", JOptionPane.WARNING_MESSAGE );
                if (loginDialog.showDialog()) {
                    // login successful - try the request again
                    loadPage("text/html", testURLs[actionsComboBox.getSelectedIndex()]);
                }
                break;
            case 903:
                JOptionPane.showMessageDialog(mainFrame, ex.getMessage(), "903 Error",
                        JOptionPane.WARNING_MESSAGE);
                break;
            case 904:
                JOptionPane.showMessageDialog(mainFrame, ex.getMessage(), "904 Error",
                        JOptionPane.WARNING_MESSAGE);
                break;
            }

        }
    };

    sessionManager.addDacsEventListener(dacsEventListener);

    init(mainFrame);

}