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:javaapplication3.SolidscapeDialog.java

public void SolidscapeDialogStart() {
    instance = new InstanceCall();
    setTitle("Add Information about" + new File(BPath.getText()).getName());
    hideErrorFields();//from w  w  w.  jav  a2s . c o m
    Date date = Calendar.getInstance().getTime();
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    this.dateRunTxt.setText(sdf.format(date));
    this.setLocationRelativeTo(null);
    //search database for buildName
    //File BPathfile = new File(BPath.getText().replace("\\", "\\\\"));
    setVisible(true);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent we) {
            String ObjButtons[] = { "Yes", "No" };
            int PromptResult = JOptionPane.showOptionDialog(null, "Save as an Open Build?", "Save",
                    JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, ObjButtons, ObjButtons[1]);
            if (PromptResult == JOptionPane.YES_OPTION) {
                gatherScrapThenExit();
                PrinterBuild.selectAllFiles("Solidscape");
                dispose();
            } else {
                ResultSet r = SolidscapeMain.dba.searchPendingByBuildName(new File(BPath.getText()).getName());
                try {
                    while (r.next()) {
                        SolidscapeMain.dba.updatePendingJobsBuildName(r.getString("buildName"),
                                r.getString("fileName"));
                    }
                } catch (SQLException ex) {
                    Logger.getLogger(SolidscapeDialog.class.getName()).log(Level.SEVERE, null, ex);
                }
                ResultSet s = SolidscapeMain.dba
                        .searchSolidscapeByBuildName(new File(BPath.getText()).getName());
                try {
                    while (s.next()) {
                        SolidscapeMain.dba.deleteByBuildName(s.getString("buildName"), "solidscape");
                    }
                } catch (SQLException ex) {
                    Logger.getLogger(SolidscapeDialog.class.getName()).log(Level.SEVERE, null, ex);
                }
                dispose();
            }
        }
    });
}

From source file:iics.Connection.java

String readfile() {

    String link = "";
    try {//w  w  w  .  j  a  va2 s. c  o m
        try (BufferedReader br = new BufferedReader(new FileReader(f1.getAbsoluteFile()))) {
            StringBuilder sb = new StringBuilder();
            String line = br.readLine();

            while (line != null) {
                sb.append(line);
                sb.append(System.lineSeparator());
                line = br.readLine();
            }
            link = sb.toString();
            // System.out.println("files "+link);
        }
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null,
                "                 An error occured!! \n Contact your system admin for help.", null,
                JOptionPane.WARNING_MESSAGE);
        close_loda();
    }
    return link;
}

From source file:net.itransformers.topologyviewer.menu.handlers.graphFileMenuHandlers.SaveCurrentGraphMenuHandler.java

@Override
public void actionPerformed(ActionEvent e) {
    File path = frame.getPath();// ww w . ja v a 2s.c om

    if (path == null) {
        JOptionPane.showMessageDialog(frame, "Can not open graph before project has been opened.");
        return;
    }

    JTextField fileName = new JTextField();
    Object[] message = { "File name", fileName };
    String versionName = JOptionPane.showInputDialog("Enter output graph version");

    File networkPath = new File(path + File.separator + ProjectConstants.networkDirName);

    File versionPath = new File(networkPath, versionName);
    if (versionPath.exists()) {
        JOptionPane.showMessageDialog(frame, "Version already exists" + versionPath.getAbsolutePath());

        return;
    }

    if (!versionPath.mkdir()) {
        JOptionPane.showMessageDialog(frame, "Unable to create version path: " + versionPath.getAbsolutePath());
    }

    if ("undirected".equalsIgnoreCase(frame.getCurrentGraphViewerManager().getGraphType().toString())) {
        graphmlDir = new File(versionPath.getAbsolutePath(), ProjectConstants.undirectedGraphmlDirName);

    } else {
        graphmlDir = new File(versionPath.getAbsolutePath(), ProjectConstants.directedGraphmlDirName);

    }
    if (!graphmlDir.mkdir()) {
        JOptionPane.showMessageDialog(frame, "Unable to create version path:" + versionPath.getAbsolutePath(),
                "Error", JOptionPane.WARNING_MESSAGE);
        return;
    }

    Writer fileWriter;
    try {
        fileWriter = new FileWriter(new File(graphmlDir, ProjectConstants.networkGraphmlFileName));
    } catch (IOException e1) {
        JOptionPane.showMessageDialog(frame, "Unable to create network.graphml file:", "Error",
                JOptionPane.WARNING_MESSAGE);
        return;
    }
    GraphViewerPanel viewerPanel = (GraphViewerPanel) frame.getTabbedPane().getSelectedComponent();
    final Graph<String, String> currentGraph = viewerPanel.getCurrentGraph();
    MyGraphMLWriter writer = new MyGraphMLWriter();
    writer.setGraphData(viewerPanel.getGraphmlLoader().getGraphMetadatas());
    writer.setVertexData(viewerPanel.getGraphmlLoader().getVertexMetadatas());
    writer.setEdgeData(viewerPanel.getGraphmlLoader().getEdgeMetadatas());
    writer.setEdgeIDs(new Transformer<String, String>() {

        @Override
        public String transform(String s) {
            Pair<String> endpoints = currentGraph.getEndpoints(s);
            String[] endpointsArr = new String[] { endpoints.getFirst(), endpoints.getSecond() };
            Arrays.sort(endpointsArr);
            return endpointsArr[0] + "_" + endpointsArr[1];
        }
    });
    boolean flag;
    try {
        writer.save(currentGraph, fileWriter);
        flag = true;

    } catch (IOException e1) {
        flag = false;
        JOptionPane.showMessageDialog(frame, "Unable to write graph file:" + e1.getMessage(), "Error",
                JOptionPane.WARNING_MESSAGE);

    }

}

From source file:SaveDialog.java

boolean okToQuit() {
    String[] choices = { "Yes, Save and Quit", "No, Quit without saving", "CANCEL" };
    int result = JOptionPane.showOptionDialog(this, "You have unsaved changes. Save before quitting?",
            "Warning", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, choices,
            choices[0]);//from   www.  j  a v a 2s. c o  m

    // Use of "null" as the Icon argument is contentious... the
    // document says you can pass null, but it does seem to
    // generate a lot of blather if you do, something about
    // a NullPointerException :-) ...

    if (result >= 0)
        System.out.println("You clicked " + choices[result]);

    switch (result) {
    case -1:
        System.out.println("You killed my die-alog - it died");
        return false;
    case 0: // save and quit
        System.out.println("Saving...");
        // mainApp.doSave();
        return true;
    case 1: // just quit
        return true;
    case 2: // cancel
        return false;
    default:
        throw new IllegalArgumentException("Unexpected return " + result);
    }
}

From source file:net.sf.firemox.network.Client.java

@Override
public void run() {
    String entree;/*ww w  .  j  av a 2s.  co m*/
    LoaderConsole.beginTask(LanguageManager.getString("wiz_network.creatingconnection") + "...", 2);
    InetAddress adr = null;
    try {
        // Connexion au serveur
        adr = InetAddress.getByName(Configuration.getString("ip"));
        clientSocket = new Socket(adr, port);
    } catch (IOException e) {
        // echec de la connexion au serveur
        JOptionPane.showMessageDialog(MagicUIComponents.magicForm,
                LanguageManager.getString("wiz_network.cannotconnectto", adr) + ", "
                        + LanguageManager.getString("wiz_network.port") + ":" + port + ". \n"
                        + LanguageManager.getString("wiz_network.port.invalid"),
                LanguageManager.getString("wiz_network.connectionpb"), JOptionPane.WARNING_MESSAGE);
        NetworkActor.cancelling = true;
        LoaderConsole.endTask();
    }

    // stopping?
    if (cancelling) {
        cancelConnexion();
        return;
    }
    LoaderConsole.beginTask(LanguageManager.getString("wiz_network.connecting"), 5);

    try {
        // Cration des flots d'entre/sortie
        outBin = clientSocket.getOutputStream();
        inBin = clientSocket.getInputStream();

        // need password?
        entree = MToolKit.readString(inBin);
        if (STR_PASSWD.equals(entree)) {
            // a password is need by this server
            if (passwd == null) {
                // ... but we haven't any
                LoaderConsole.beginTask(LanguageManager.getString("wiz_network.password.missed"));
                MToolKit.writeString(outBin, STR_NOPASSWD);
                // close stream
                IOUtils.closeQuietly(inBin);
                IOUtils.closeQuietly(outBin);
                // free pointers
                outBin = null;
                inBin = null;
            } else {
                // send our password
                MToolKit.writeString(outBin, new String(passwd));
                entree = MToolKit.readString(inBin);
                if (STR_WRONGPASSWD.equals(entree)) {
                    // wrong password
                    LoaderConsole.beginTask(LanguageManager.getString("wiz_network.password.invalid"));
                    // close stream
                    IOUtils.closeQuietly(inBin);
                    IOUtils.closeQuietly(outBin);
                    // free pointers
                    outBin = null;
                    inBin = null;
                }
            }
        }
        if (outBin != null && !STR_OK.equals(entree)) {
            LoaderConsole.beginTask(LanguageManager.getString("wiz_network.unknowncommand") + entree);
            // close stream
            IOUtils.closeQuietly(inBin);
            IOUtils.closeQuietly(outBin);
            // free pointers
            outBin = null;
            inBin = null;
        }
        if (outBin != null) {
            // send our version
            MToolKit.writeString(outBin, IdConst.VERSION);
            entree = MToolKit.readString(inBin);
            if (STR_WRONGVERSION.equals(entree)) {
                // wrong version
                LoaderConsole.beginTask(LanguageManager.getString("wiz_network.differentversionpb"));
                // close stream
                IOUtils.closeQuietly(inBin);
                IOUtils.closeQuietly(outBin);
                // free pointers
                outBin = null;
                inBin = null;
            }
        }
        if (outBin != null && !STR_OK.equals(entree)) {
            LoaderConsole.beginTask(LanguageManager.getString("wiz_network.unknowncommand") + entree);
            // close stream
            IOUtils.closeQuietly(inBin);
            IOUtils.closeQuietly(outBin);
            // free pointers
            outBin = null;
            inBin = null;
        }

        if (outBin != null) {
            /*
             * client is connected to the server client/serveur I am ...
             */
            MToolKit.writeString(outBin, nickName);
            // Opponent is ...
            String serverName = MToolKit.readString(inBin);
            LoaderConsole.beginTask(LanguageManager.getString("wiz_network.opponentis") + serverName, 10);

            // exchange shared string settings
            ((Opponent) StackManager.PLAYERS[1]).readSettings(serverName, nickName, inBin);
            ((You) StackManager.PLAYERS[0]).sendSettings(outBin);

            // stopping?
            if (cancelling) {
                cancelConnexion();
                return;
            }

            // receive, and set the random seed
            long seed = Long.parseLong(MToolKit.readString(inBin));
            MToolKit.random.setSeed(seed);
            Log.info("Seed = " + seed);

            // read mana use option
            PayMana.useMana = Integer.parseInt(MToolKit.readString(inBin)) == 1;

            // read opponent response option
            WaitActivatedChoice.opponentResponse = Integer.parseInt(MToolKit.readString(inBin)) == 1;

            // Who starts?
            final StartingOption startingOption = StartingOption.values()[Integer
                    .valueOf(MToolKit.readString(inBin)).intValue()];
            final boolean serverStarts;
            switch (startingOption) {
            case random:
            default:
                serverStarts = MToolKit.random.nextBoolean();
                break;
            case server:
                serverStarts = true;
                break;
            case client:
                serverStarts = false;
            }

            if (serverStarts) {
                // server begins
                LoaderConsole.beginTask(LanguageManager.getString("wiz_network.opponentwillstart") + " (mode="
                        + startingOption.getLocaleValue() + ")", 15);
                StackManager.idActivePlayer = 1;
                StackManager.idCurrentPlayer = 1;
            } else {
                // client begins
                LoaderConsole.beginTask(LanguageManager.getString("wiz_network.youwillstarts") + " (mode="
                        + startingOption.getLocaleValue() + ")", 15);
                StackManager.idActivePlayer = 0;
                StackManager.idCurrentPlayer = 0;
            }

            // load rules from the MDB file
            dbStream = MdbLoader.loadMDB(MToolKit.mdbFile, StackManager.idActivePlayer);
            TableTop.getInstance().initTbs();

            // send our deck
            LoaderConsole.beginTask(LanguageManager.getString("wiz_network.sendingdeck"), 25);
            deck.send(outBin);
            StackManager.PLAYERS[0].zoneManager.giveCards(deck, dbStream);
            MToolKit.writeString(outBin, "%EOF%");
            outBin.flush();

            // stopping?
            if (cancelling) {
                cancelConnexion();
                return;
            }

            // receive her/his deck
            LoaderConsole.beginTask(LanguageManager.getString("wiz_network.receivingdeck"), 55);
            readAndValidateOpponentDeck();

            // free resources
            LoaderConsole.setTaskPercent(100);

            // stopping?
            if (cancelling) {
                cancelConnexion();
                return;
            }

            // stopping?
            if (cancelling) {
                cancelConnexion();
                return;
            }

            initBigPipe();
            MagicUIComponents.magicForm.initGame();
        }
    } catch (Throwable e) {
        NetworkActor.cancelling = true;
        LoaderConsole.endTask();
        cancelConnexion();
        Log.error(e);
        throw new RuntimeException(LanguageManager.getString("wiz_network.badconnection", adr), e);
    }
}

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

private void deleteAllButtonActionPerformed(ActionEvent e) {
    int response = JOptionPane.showConfirmDialog(this,
            "Se borrarn todos los tags de la base de datos.\nEsta operacin no se puede deshacer.\nContinuar?",
            "Borrar todos los tags", JOptionPane.WARNING_MESSAGE);
    if (response == JOptionPane.YES_OPTION) {
        try {/*from   w  ww.j  av  a 2  s .  c o  m*/
            rfidDao.deleteAll();
            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:de.mpg.mpi_inf.bioinf.netanalyzer.dec.LeastSquaresPowerLawDecorator.java

@Override
public void decorate(JDialog aOwner, JFreeChart aChart, ComplexParamVisualizer aVisualizer, boolean aVerbose) {
    clearDataset(aChart, seriesName);/*from ww  w  . j  a v a 2 s. co m*/
    final Point2D.Double[] dataPoints = JFreeChartConn.extractData(aChart);
    final Point2D.Double[] posPoints = keepPositive(dataPoints);
    if (posPoints != dataPoints && aVerbose) {
        // Display a warning that not all points will be included in the fit
        if (aVerbose) {
            JOptionPane.showMessageDialog(aOwner, Messages.SM_FITNONPOSITIVE, Messages.DT_FIT,
                    JOptionPane.WARNING_MESSAGE);
        }
    }
    if (posPoints.length < 2) {
        // Error - not enough data points
        if (aVerbose) {
            Utils.showErrorBox(aOwner, Messages.DT_FIT, Messages.SM_FITPLNODATA);
        }
        return;
    }
    coefs = Fitter.leastSquaresPowerLawFit(posPoints);

    if (coefs != null) {
        final XYSeries newData = createFittingData(posPoints, isLogLog(aVisualizer.getSettings()));
        final XYPlot plot = aChart.getXYPlot();
        int i = getDatasetIndex(plot, seriesName);
        if (i == -1) {
            i = createDataset(plot);
        }
        plot.setDataset(i, new XYSeriesCollection(newData));

        if (aVerbose) {
            // Compute correlation
            final int count = posPoints.length;
            final double[] s1 = new double[count];
            final double[] s2 = new double[count];
            for (int j = 0; j < count; ++j) {
                s1[j] = posPoints[j].y;
                s2[j] = valueAt(posPoints[j].x);
            }
            Double corr = null;
            Double rsquared = null;
            try {
                corr = new Double(Fitter.computeCorr(s1, s2));
            } catch (ArithmeticException ex) {
                // Correlation could not be computed; ignore
            }
            try {
                ArrayUtils.log(s1, true);
                ArrayUtils.log(s2, true);
                rsquared = new Double(Fitter.computeRSquared(s1, s2));
            } catch (ArithmeticException ex) {
                // R-Squared could not be computed; ignore
            }

            // Inform the user what the coefficients are
            showReport(aOwner, corr, rsquared);
        }
    } else {
        // Could not fit power law
        if (aVerbose) {
            Utils.showErrorBox(aOwner, Messages.DT_FIT, Messages.SM_FITPLERROR);
        }
    }
}

From source file:javaapplication3.ObjetDialog.java

public void ObjetDialogStart() {
    instance = new InstanceCall();
    setTitle("Add Information about" + new File(BPath.getText()).getName());
    hideErrorFields();//  w w w  .ja va  2  s  .  c om
    Date date = Calendar.getInstance().getTime();
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    this.dateRunTxt.setText(sdf.format(date));
    this.setLocationRelativeTo(null);
    //search database for buildName
    //File BPathfile = new File(BPath.getText().replace("\\", "\\\\"));
    setVisible(true);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent we) {
            String ObjButtons[] = { "Yes", "No" };
            int PromptResult = JOptionPane.showOptionDialog(null, "Save as an Open Build?", "Save",
                    JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, ObjButtons, ObjButtons[1]);
            if (PromptResult == JOptionPane.YES_OPTION) {
                gatherScrapThenExit();
                PrinterBuild.selectAllFiles("Objet");
                dispose();
            } else {
                ResultSet r = ObjetMain.dba.searchPendingByBuildName(new File(BPath.getText()).getName());
                try {
                    while (r.next()) {
                        ObjetMain.dba.updatePendingJobsBuildName(r.getString("buildName"),
                                r.getString("fileName"));
                    }
                } catch (SQLException ex) {
                    Logger.getLogger(ObjetDialog.class.getName()).log(Level.SEVERE, null, ex);
                }
                ResultSet s = ObjetMain.dba.searchObjetByBuildName(new File(BPath.getText()).getName());
                try {
                    while (s.next()) {
                        ObjetMain.dba.deleteByBuildName(s.getString("buildName"), "objet");
                    }
                } catch (SQLException ex) {
                    Logger.getLogger(ObjetDialog.class.getName()).log(Level.SEVERE, null, ex);
                }
                dispose();
            }
        }
    });
}

From source file:com.aw.swing.mvp.ui.msg.MessageDisplayerImpl.java

public static boolean showConfirmMessage(Frame frame, String messageConfirm, int defaultButton) {
    return showConfirmMessage(frame, messageConfirm, JOptionPane.WARNING_MESSAGE, defaultButton);
}

From source file:javaapplication3.ZCorpDialog.java

public void ZCorpDialogStart() {
    instance = new InstanceCall();
    setTitle("Add Information about" + new File(BPath.getText()).getName());
    hideErrorFields();//  w  w  w.j  ava  2 s  .co  m
    Date date = Calendar.getInstance().getTime();
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    this.dateRunTxt.setText(sdf.format(date));
    this.setLocationRelativeTo(null);
    //search database for buildName
    //File BPathfile = new File(BPath.getText().replace("\\", "\\\\"));
    setVisible(true);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent we) {
            String ObjButtons[] = { "Yes", "No" };
            int PromptResult = JOptionPane.showOptionDialog(null, "Save as an Open Build?", "Save",
                    JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, ObjButtons, ObjButtons[1]);
            if (PromptResult == JOptionPane.YES_OPTION) {
                gatherScrapThenExit();
                PrinterBuild.selectAllFiles("ZCorp");
                dispose();
            } else {
                ResultSet r = ZCorpMain.dba.searchPendingByBuildName(new File(BPath.getText()).getName());
                try {
                    while (r.next()) {
                        ZCorpMain.dba.updatePendingJobsBuildName(r.getString("buildName"),
                                r.getString("fileName"));
                    }
                } catch (SQLException ex) {
                    Logger.getLogger(ZCorpDialog.class.getName()).log(Level.SEVERE, null, ex);
                }
                ResultSet s = ZCorpMain.dba.searchZCorpByBuildName(new File(BPath.getText()).getName());
                try {
                    while (s.next()) {
                        ZCorpMain.dba.deleteByBuildName(s.getString("buildName"), "zcorp");
                    }
                } catch (SQLException ex) {
                    Logger.getLogger(ZCorpDialog.class.getName()).log(Level.SEVERE, null, ex);
                }
                dispose();
            }
        }
    });
}