List of usage examples for javax.swing JOptionPane INFORMATION_MESSAGE
int INFORMATION_MESSAGE
To view the source code for javax.swing JOptionPane INFORMATION_MESSAGE.
Click Source Link
From source file:MainClass.java
public static void main(String[] a) { String msg = "<html>this is a really long message<br>this is a really long message this is a really long message this is a really long message this is a really long message this is a really long message this is a really long message"; JOptionPane optionPane = new JOptionPane(); optionPane.setMessage(msg);// w w w . jav a2s. co m optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); JDialog dialog = optionPane.createDialog(null, "Width 100"); dialog.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JOptionPane pane = new JOptionPane("JOptionPane", JOptionPane.INFORMATION_MESSAGE); String dialogTitle = "Resizable Custom Dialog"; JDialog dialog = pane.createDialog(dialogTitle); dialog.setResizable(true);// w w w . j av a2 s . c o m dialog.setVisible(true); }
From source file:ComplexMessageDemo.java
public static void main(String[] a) { Object complexMsg[] = { "Above Message", new ImageIcon("yourFile.gif"), new JButton("Hello"), new JSlider(), new ImageIcon("yourFile.gif"), "Below Message" }; JOptionPane optionPane = new JOptionPane(); optionPane.setMessage(complexMsg);//from ww w . j av a 2 s . c o m optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); JDialog dialog = optionPane.createDialog(null, "Width 100"); dialog.setVisible(true); }
From source file:AddingButtonWithActionListener.java
public static void main(String[] a) { JFrame frame = new JFrame(); JOptionPane optionPane = new JOptionPane(); optionPane.setMessage("I got an icon and a text label"); optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); Icon icon = new ImageIcon("yourFile.gif"); JButton jButton = getButton(optionPane, "OK", icon); optionPane.setOptions(new Object[] { jButton }); JDialog dialog = optionPane.createDialog(frame, "Icon/Text Button"); dialog.setVisible(true);/*from ww w .j a v a2 s . co m*/ }
From source file:DisplayingMultilineMessages.java
public static void main(String[] a) { String msg = "<html>this is a really long message<br>this is a really long message this is a really long message this is a really long message this is a really long message this is a really long message this is a really long message"; JOptionPane optionPane = new NarrowOptionPane(); optionPane.setMessage(msg);//from w w w .j ava 2s . c om optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); JDialog dialog = optionPane.createDialog(null, "Width 100"); dialog.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { URL url = new URL("http://www.java2s.com/style/download.png"); Image chunk = readFragment(url.openStream(), new Rectangle(15, 15, 30, 25)); JOptionPane.showMessageDialog(null, new ImageIcon(chunk), "Duke", JOptionPane.INFORMATION_MESSAGE); }
From source file:Main.java
public static void main(String[] args) { int TIME_VISIBLE = 3000; JFrame frame1 = new JFrame(); frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame1.setSize(100, 100);//w w w. ja v a 2 s . c o m frame1.setLocation(100, 100); JButton button = new JButton("My Button"); frame1.getContentPane().add(button); button.addActionListener(e -> { JOptionPane pane = new JOptionPane("Message", JOptionPane.INFORMATION_MESSAGE); JDialog dialog = pane.createDialog(null, "Title"); dialog.setModal(false); dialog.setVisible(true); new Timer(TIME_VISIBLE, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); } }).start(); }); frame1.setVisible(true); }
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.ja va 2 s . c o m*/ 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:appmain.AppMain.java
public static void main(String[] args) { try {/*from www . j a v a 2 s. c om*/ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIManager.put("OptionPane.yesButtonText", "Igen"); UIManager.put("OptionPane.noButtonText", "Nem"); } catch (Exception ex) { ex.printStackTrace(); } try { AppMain app = new AppMain(); app.init(); File importFolder = new File(DEFAULT_IMPORT_FOLDER); if (!importFolder.isDirectory() || !importFolder.exists()) { JOptionPane.showMessageDialog(null, "Az IMPORT mappa nem elrhet!\n" + "Ellenrizze az elrsi utat s a jogosultsgokat!\n" + "Mappa: " + importFolder.getAbsolutePath(), "Informci", JOptionPane.INFORMATION_MESSAGE); return; } File exportFolder = new File(DEFAULT_EXPORT_FOLDER); if (!exportFolder.isDirectory() || !exportFolder.exists()) { JOptionPane.showMessageDialog(null, "Az EXPORT mappa nem elrhet!\n" + "Ellenrizze az elrsi utat s a jogosultsgokat!\n" + "Mappa: " + exportFolder.getAbsolutePath(), "Informci", JOptionPane.INFORMATION_MESSAGE); return; } List<File> xmlFiles = app.getXMLFiles(importFolder); if (xmlFiles == null || xmlFiles.isEmpty()) { JOptionPane.showMessageDialog(null, "Nincs beolvasand XML fjl!\n" + "Mappa: " + importFolder.getAbsolutePath(), "Informci", JOptionPane.INFORMATION_MESSAGE); return; } StringBuilder fileList = new StringBuilder(); xmlFiles.stream().forEach(xml -> fileList.append("\n").append(xml.getName())); int ret = JOptionPane.showConfirmDialog(null, "Beolvassra elksztett fjlok:\n" + fileList + "\n\nIndulhat a feldolgozs?", "Megtallt XML fjlok", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (ret == JOptionPane.OK_OPTION) { String csvName = "tranzakcio_lista_" + df.format(new Date()) + "_" + System.currentTimeMillis() + ".csv"; File csv = new File(DEFAULT_EXPORT_FOLDER + "/" + csvName); app.writeCSV(csv, Arrays.asList(app.getHeaderLine())); xmlFiles.stream().forEach(xml -> { List<String> lines = app.readXMLData(xml); if (lines != null) app.writeCSV(csv, lines); }); if (csv.isFile() && csv.exists()) { JOptionPane.showMessageDialog(null, "A CSV fjl sikeresen elllt!\n" + "Fjl: " + csv.getAbsolutePath(), "Informci", JOptionPane.INFORMATION_MESSAGE); app.openFile(csv); } } else { JOptionPane.showMessageDialog(null, "Feldolgozs megszaktva!", "Informci", JOptionPane.INFORMATION_MESSAGE); } } catch (Exception ex) { JOptionPane.showMessageDialog(null, "Nem kezelt kivtel!\n" + ExceptionUtils.getStackTrace(ex), "Hiba", JOptionPane.ERROR_MESSAGE); } }
From source file:MessagePopup.java
public static void main(String args[]) { JFrame frame = new JFrame("Message Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button = new JButton("Pop it"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Component source = (Component) actionEvent.getSource(); /*/*from w w w .ja va2 s . com*/ * // String msg = "this is a really long message this is a * really long message this is a really long message this is a * really long message this is a really long message this is a * really long message this is a really long message"; String * msg = " <html>this is a really long message <br> this is a * really long message this is a really long message this is a * really long message this is a really long message this is a * really long message this is a really long message"; * JOptionPane.showMessageDialog(source, msg); JOptionPane * optionPane = OptionPaneUtils.getNarrowOptionPane(72); * optionPane.setMessage(msg); * optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); * JDialog dialog = optionPane.createDialog(source, "Width 72"); * dialog.show(); int selection = * OptionPaneUtils.getSelection(optionPane); * JOptionPane.showMessageDialog(source, msg); String * multiLineMsg[] = {"Hello", "World"}; * JOptionPane.showMessageDialog(source, multiLineMsg); * * Object complexMsg[] = {"Above Message", new * DiamondIcon(Color.red), new JButton ("Hello"), new JSlider(), * new DiamondIcon(Color.blue), "Below Message"}; * JOptionPane.showInputDialog(source, complexMsg); JOptionPane * optionPane = new JOptionPane(); JSlider slider = * OptionPaneUtils.getSlider(optionPane); * optionPane.setMessage(new Object[] {"Select a value: " , * slider}); * optionPane.setMessageType(JOptionPane.QUESTION_MESSAGE); * optionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION); * JDialog dialog = optionPane.createDialog(source, "My * Slider"); dialog.show(); System.out.println ("Input: " + * optionPane.getInputValue()); */ JOptionPane optionPane = new JOptionPane(); optionPane.setMessage("I got an icon and a text label"); optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); Icon icon = new DiamondIcon(Color.blue); JButton jButton = OptionPaneUtils.getButton(optionPane, "OK", icon); optionPane.setOptions(new Object[] { jButton }); JDialog dialog = optionPane.createDialog(source, "Icon/Text Button"); dialog.show(); } }; button.addActionListener(actionListener); Container contentPane = frame.getContentPane(); contentPane.add(button, BorderLayout.SOUTH); frame.setSize(300, 200); frame.setVisible(true); }