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

public static void main(String[] a) {
    String input = JOptionPane.showInputDialog(null, "Enter Input:", "Dialog for Input",
            JOptionPane.WARNING_MESSAGE);
    System.out.println(input);//from  w ww.j ava  2  s .  co m
}

From source file:JOptionPaneWARNING_MESSAGE.java

public static void main(String[] args) {
    final JPanel panel = new JPanel();

    JOptionPane.showMessageDialog(panel, "A deprecated call", "Warning", JOptionPane.WARNING_MESSAGE);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    String[] buttons = { "Yes", "Yes to all", "No", "Cancel" };

    int rc = JOptionPane.showOptionDialog(null, "Question ?", "Confirmation", JOptionPane.WARNING_MESSAGE, 0,
            null, buttons, buttons[2]);/* w  ww.j ava  2 s . c o  m*/

    System.out.println(rc);

}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(200, 200);//from www . j a va 2s.co m
    frame.setVisible(true);

    JOptionPane.showMessageDialog(frame, "A");
    JOptionPane.showMessageDialog(frame, "B", "message", JOptionPane.WARNING_MESSAGE);

    int result = JOptionPane.showConfirmDialog(null, "Remove now?");
    switch (result) {
    case JOptionPane.YES_OPTION:
        System.out.println("Yes");
        break;
    case JOptionPane.NO_OPTION:
        System.out.println("No");
        break;
    case JOptionPane.CANCEL_OPTION:
        System.out.println("Cancel");
        break;
    case JOptionPane.CLOSED_OPTION:
        System.out.println("Closed");
        break;
    }

    String name = JOptionPane.showInputDialog(null, "Please enter your name.");
    System.out.println(name);

    JTextField userField = new JTextField();
    JPasswordField passField = new JPasswordField();
    String message = "Please enter your user name and password.";
    result = JOptionPane.showOptionDialog(frame, new Object[] { message, userField, passField }, "Login",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
    if (result == JOptionPane.OK_OPTION)
        System.out.println(userField.getText() + " " + new String(passField.getPassword()));

}

From source file:Main.java

public static void main(String[] args) {
    String text = "one two three four five six seven eight nine ten ";
    JTextArea textArea = new JTextArea(text);
    textArea.setColumns(30);/*from  w ww  . j ava2  s . c o  m*/
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.append(text);
    textArea.append(text);
    textArea.append(text);
    textArea.append(text);
    textArea.append(text);
    textArea.setSize(textArea.getPreferredSize().width, 1);
    JOptionPane.showMessageDialog(null, new JScrollPane(textArea), "Not Truncated!",
            JOptionPane.WARNING_MESSAGE);
}

From source file:driver.ieSystem2.java

public static void main(String[] args) throws SQLException {

    Scanner sc = new Scanner(System.in);
    boolean login = false;
    int check = 0;
    int id = 0;/*from  w  w  w  . j ava  2 s .  c  om*/
    String user = "";
    String pass = "";
    Person person = null;
    Date day = null;

    JOptionPane.showMessageDialog(null, "WELCOME TO SYSTEM", "Starting Project",
            JOptionPane.INFORMATION_MESSAGE);
    do {
        System.out.println("What do you want?");
        System.out.println("press 1 : Login");
        System.out.println("press 2 : Create New User");
        System.out.println("Press 3 : Exit ");
        System.out.println("");
        do {
            try {
                System.out.print("Enter: ");
                check = sc.nextInt();
            } catch (InputMismatchException e) {
                JOptionPane.showMessageDialog(null, "Invalid Input", "Message", JOptionPane.WARNING_MESSAGE);
                sc.next();
            }
        } while (check <= 1 && check >= 3);

        // EXIT 
        if (check == 3) {
            System.out.println("Close Application");
            System.exit(0);
        }
        // CREATE USER
        if (check == 2) {
            System.out.println("-----------------------------------------");
            System.out.println("Create New User");
            System.out.println("-----------------------------------------");
            System.out.print("Account ID: ");
            id = sc.nextInt();
            System.out.print("Username: ");
            user = sc.next();
            System.out.print("Password: ");
            pass = sc.next();
            try {
                Person.createUser(id, user, pass, 0, 0, 0, 0, 0);
                System.out.println("-----------------------------------------");
                System.out.println("Create Complete");
                System.out.println("-----------------------------------------");
            } catch (Exception e) {
                System.out.println("-----------------------------------------");
                System.out.println("Error, Try again");
                System.out.println("-----------------------------------------");
            }
        } else if (check == 1) {
            // LOGIN
            do {
                System.out.println("-----------------------------------------");
                System.out.println("LOGIN ");
                System.out.print("Username: ");
                user = sc.next();
                System.out.print("Password: ");
                pass = sc.next();
                if (Person.checkUser(user, pass)) {
                    System.out.println("-----------------------------------------");
                    System.out.println("Login Complete");
                } else {
                    System.out.println("-----------------------------------------");
                    System.out.println("Invalid Username / Password");
                }
            } while (!Person.checkUser(user, pass));
        }
    } while (check != 1);
    login = true;

    person = new Person(user);
    do {
        System.out.println("-----------------------------------------");
        System.out.println("Hi " + person.getPerName());
        System.out.println("Press 1 : Add Income");
        System.out.println("Press 2 : Add Expense");
        System.out.println("Press 3 : Add Save");
        System.out.println("Press 4 : History");
        System.out.println("Press 5 : Search");
        System.out.println("Press 6 : Analytics");
        System.out.println("Press 7 : Total");
        System.out.println("Press 8 : All Summary");
        System.out.println("Press 9 : Sign Out");
        do {
            try {
                System.out.print("Enter : ");
                check = sc.nextInt();
            } catch (InputMismatchException e) {
                System.out.println("Invalid Input");
                sc.next();
            }
        } while (check <= 1 && check >= 5);
        // Add Income
        if (check == 1) {
            double Income;
            String catalog = "";
            double IncomeTotal = 0;
            catalog = JOptionPane.showInputDialog("What is your income : ");
            Income = Integer.parseInt(JOptionPane.showInputDialog("How much is it   "));

            person.addIncome(person.getPerId(), day, catalog, Income);
            person.update();
        } //Add Expense
        else if (check == 2) {
            double Expense;
            String catalog = "";
            catalog = JOptionPane.showInputDialog("What is your expense :");
            Expense = Integer.parseInt(JOptionPane.showInputDialog("How much is it   "));
            person.addExpense(person.getPerId(), day, catalog, Expense);
            person.update();
        } //Add Save 
        else if (check == 3) {
            double Saving;
            double SavingTotal = 0;
            String catalog = "";

            Saving = Integer.parseInt(JOptionPane.showInputDialog("How much is it "));
            SavingTotal += Saving;
            person.addSave(person.getPerId(), day, catalog, Saving);
            person.update();
        } //History
        else if (check == 4) {
            String x;
            do {
                System.out.println("-----------------------------------------");
                System.out.println("YOUR HISTORY");
                System.out.println("Date                Type           Amount");
                System.out.println("-----------------------------------------");
                List<History> history = person.getHistory();
                if (history != null) {
                    int count = 1;
                    for (History h : history) {
                        if (count++ <= 1) {
                            System.out.println(h.getHistoryDateTime() + "   " + h.getHistoryDescription()
                                    + "           " + h.getAmount());
                        } else {
                            System.out.println(h.getHistoryDateTime() + "   " + h.getHistoryDescription()
                                    + "           " + h.getAmount());
                        }
                    }
                }
                System.out.println("-----------------------------------------");
                System.out.print("Back to menu (0 or back) : ");
                x = sc.next();
            } while (!x.equalsIgnoreCase("back") && !x.equalsIgnoreCase("0"));
        } //Searh
        else if (check == 5) {
            try {
                Connection conn = ConnectionDB.getConnection();
                long a = person.getPerId();
                String NAME = "Salary";
                PreparedStatement ps = conn.prepareStatement(
                        "SELECT * FROM  INCOME WHERE PERID = " + a + "  and CATALOG LIKE '%" + NAME + "%' ");
                ResultSet rec = ps.executeQuery();

                while ((rec != null) && (rec.next())) {
                    System.out.print(rec.getDate("Days"));
                    System.out.print(" - ");
                    System.out.print(rec.getString("CATALOG"));
                    System.out.print(" - ");
                    System.out.print(rec.getDouble("AMOUNT"));
                    System.out.print(" - ");
                }
                ps.close();
                conn.close();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        } //Analy 
        else if (check == 6) {
            String x;
            do {
                DecimalFormat df = new DecimalFormat("##.##");
                double in = person.getIncome();
                double ex = person.getExpense();
                double sum = person.getSumin_ex();
                System.out.println("-----------------------------------------");
                System.out.println("Income : " + df.format((in / sum) * 100) + "%");
                System.out.println("Expense : " + df.format((ex / sum) * 100) + "%");
                System.out.println("\n\n");
                System.out.print("Back to menu (0 or back) : ");
                x = sc.next();
            } while (!x.equalsIgnoreCase("back") && !x.equalsIgnoreCase("0"));
        } //TOTAL
        else if (check == 7) {
            String x;
            do {
                System.out.println("-----------------------------------------");
                System.out.println("TOTALSAVE             TOTAL");
                System.out.println(
                        person.getTotalSave() + " Baht" + "             " + person.getTotal() + " Baht");
                System.out.println("\n\n");
                System.out.print("Back to menu (0 or back) : ");
                x = sc.next();
            } while (!x.equalsIgnoreCase("back") && !x.equalsIgnoreCase("0"));
        } //ALL Summy
        else if (check == 8) {
            String x;
            do {
                DecimalFormat df = new DecimalFormat("##.##");
                double in = person.getIncome();
                double ex = person.getExpense();
                double sum = person.getSumin_ex();
                double a = ((in / sum) * 100);
                double b = ((ex / sum) * 100);
                System.out.println("-----------------------------------------");
                System.out.println("ALL SUMMARY");
                System.out.println("Account: " + person.getPerName());
                System.out.println("");
                System.out.println("Total Save ------------- Total");
                System.out
                        .println(person.getTotalSave() + " Baht               " + person.getTotal() + " Baht");
                System.out.println("");

                System.out.println("INCOME --------------- EXPENSE");
                System.out.println(df.format(a) + "%" + "                  " + df.format(b) + "%");

                System.out.println("-----------------------------------------");
                System.out.println("\n\n");
                System.out.print("Back to menu (0 or back) : ");
                x = sc.next();
            } while (!x.equalsIgnoreCase("back") && !x.equalsIgnoreCase("0"));
        } //LOG OUT 
        else {
            System.out.println("See ya.\n");
            login = false;
            break;
        }
    } while (true);
}

From source file:net.openbyte.Launch.java

/**
 * This is the main method that allows Java to initiate the program.
 *
 * @param args the arguments to the Java program, which are ignored
 *//*from  w  w w  . ja va2  s .c  o  m*/
public static void main(String[] args) {
    logger.info("Checking for a new version...");
    try {
        GitHub gitHub = new GitHubBuilder().withOAuthToken("e5b60cea047a3e44d4fc83adb86ea35bda131744 ").build();
        GHRepository repository = gitHub.getUser("PizzaCrust").getRepository("OpenByte");
        for (GHRelease release : repository.listReleases()) {
            double releaseTag = Double.parseDouble(release.getTagName());
            if (CURRENT_VERSION < releaseTag) {
                logger.info("Version " + releaseTag + " has been released.");
                JOptionPane.showMessageDialog(null,
                        "Please update OpenByte to " + releaseTag
                                + " at https://github.com/PizzaCrust/OpenByte.",
                        "Update", JOptionPane.WARNING_MESSAGE);
            } else {
                logger.info("OpenByte is at the latest version.");
            }
        }
    } catch (Exception e) {
        logger.error("Failed to connect to GitHub.");
        e.printStackTrace();
    }
    logger.info("Checking for a workspace folder...");
    if (!Files.WORKSPACE_DIRECTORY.exists()) {
        logger.info("Workspace directory not found, creating one.");
        Files.WORKSPACE_DIRECTORY.mkdir();
    }
    logger.info("Checking for a plugins folder...");
    if (!Files.PLUGINS_DIRECTORY.exists()) {
        logger.info("Plugins directory not found, creating one.");
        Files.PLUGINS_DIRECTORY.mkdir();
    }
    try {
        logger.info("Grabbing and applying system look and feel...");
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
            | UnsupportedLookAndFeelException e) {
        logger.info("Something went wrong when applying the look and feel, using the default one...");
        e.printStackTrace();
    }
    logger.info("Starting event manager...");
    EventManager.init();
    logger.info("Detecting plugin files...");
    File[] pluginFiles = PluginManager.getPluginFiles(Files.PLUGINS_DIRECTORY);
    logger.info("Detected " + pluginFiles.length + " plugin files in the plugins directory!");
    logger.info("Beginning load/register plugin process...");
    for (File pluginFile : pluginFiles) {
        logger.info("Loading file " + FilenameUtils.removeExtension(pluginFile.getName()) + "...");
        try {
            PluginManager.registerAndLoadPlugin(pluginFile);
        } catch (Exception e) {
            logger.error("Failed to load file " + FilenameUtils.removeExtension(pluginFile.getName()) + "!");
            e.printStackTrace();
        }
    }
    logger.info("All plugin files were loaded/registered to OpenByte.");
    logger.info("Showing graphical interface to user...");
    WelcomeFrame welcomeFrame = new WelcomeFrame();
    welcomeFrame.setVisible(true);
}

From source file:com.ln.gui.Main.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                createandshowgui();//from   w w w . j  a  v a  2s. c  o m
            } catch (Exception e) {
                //Kill&print on errors
                e.printStackTrace();
                JOptionPane.showMessageDialog(null, e.getStackTrace(), "Error", JOptionPane.WARNING_MESSAGE);
            }
        }
    });
}

From source file:ch.admin.hermes.etl.load.HermesETLApplication.java

/**
 * Hauptprogramm/*from w w  w  .  j  a  v  a2s  .  co  m*/
 * @param args Commandline Argumente
 */
public static void main(String[] args) {
    JFrame frame = null;
    try {
        // Crawler fuer Zugriff auf HERMES 5 Online Loesung initialiseren */
        crawler = new HermesOnlineCrawler();

        // CommandLine Argumente aufbereiten
        parseCommandLine(args);

        // Methoden Export (Variante Zuehlke) extrahieren
        System.out.println("load library " + model);
        ModelExtract root = new ModelExtract();
        root.extract(model);

        frame = createProgressDialog();
        // wird das XML Model von HERMES Online geholt - URL der Templates korrigieren
        if (scenario != null) {
            List<Workproduct> workproducts = (List<Workproduct>) root.getObjects().get("workproducts");
            for (Workproduct wp : workproducts)
                for (Template t : wp.getTemplate()) {
                    // Template beinhaltet kompletten URL - keine Aenderung
                    if (t.getUrl().toLowerCase().startsWith("http")
                            || t.getUrl().toLowerCase().startsWith("file"))
                        continue;
                    // Model wird ab Website geholte
                    if (model.startsWith("http"))
                        t.setUrl(crawler.getTemplateURL(scenario, t.getUrl()));
                    // Model ist lokal - Path aus model und relativem Path Template zusammenstellen
                    else {
                        File m = new File(model);
                        t.setUrl(m.getParentFile() + "/" + t.getUrl());
                    }
                }
        }

        // JavaScript - fuer Import in Fremdsystem
        if (script.endsWith(".js")) {
            final JavaScriptEngine js = new JavaScriptEngine();
            js.setObjects(root.getObjects());
            js.put("progress", progress);
            js.eval("function log( x ) { println( x ); progress.setString( x ); }");
            progress.setString("call main() in " + script);
            js.put(ScriptEngine.FILENAME, script);
            js.call(new InputStreamReader(new FileInputStream(script)), "main",
                    new Object[] { site, user, passwd });
        }
        // FreeMarker - fuer Umwandlungen nach HTML
        else if (script.endsWith(".ftl")) {
            FileOutputStream out = new FileOutputStream(
                    new File(script.substring(0, script.length() - 3) + "html "));
            int i = script.indexOf("templates");
            if (i >= 0)
                script = script.substring(i + "templates".length());
            MethodTransform transform = new MethodTransform();
            transform.transform(root.getObjects(), script, out);
            out.close();
        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e.toString(), "Fehlerhafte Verarbeitung",
                JOptionPane.WARNING_MESSAGE);
        e.printStackTrace();
    }
    if (frame != null) {
        frame.setVisible(false);
        frame.dispose();
    }
    System.exit(0);
}

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

/**
 * Application entry point/*from w w w.j  a va  2  s  .  c o m*/
 * 
 * @param args
 */
public static void main(String[] args) {
    try {
        // Set System L&F
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (UnsupportedLookAndFeelException e) {
        // handle exception
    } catch (ClassNotFoundException e) {
        // handle exception
    } catch (InstantiationException e) {
        // handle exception
    } catch (IllegalAccessException e) {
        // handle exception
    }

    logger.info(systemProperties.java_version);
    logger.info(systemProperties.arch_data_model);
    logger.info(systemProperties.java_home);
    logger.info(systemProperties.user_dir);
    if (systemProperties.arch_data_model.equals(InstallUtils.AMD64)) {
        JOptionPane.showMessageDialog(null, "Se requiere Java 32bits para ejecutar este programa",
                "Systema de 64 bits", JOptionPane.WARNING_MESSAGE);
        JInstaller installer = new JInstaller(null);
        installer.setVisible(true);
    } else {
        if (!(systemProperties.getJava_version().startsWith("1.6")
                || systemProperties.getJava_version().startsWith("1.7"))) {
            JOptionPane.showMessageDialog(null, "Se requiere Java 6 o 7 para ejecutar este programa",
                    "Versin de Java no soportada", JOptionPane.WARNING_MESSAGE);
            JInstaller installer = new JInstaller(null);
            installer.setVisible(true);
        } else {
            JMuestraDatos reader = new JMuestraDatos();
            reader.setVisible(true);
        }
    }
}