1 23 24 29 30 package com.sun.enterprise.util.diagnostics; 31 32 import javax.swing.JOptionPane ; 33 34 60 public class Reminder 61 { 62 68 public static void message(String msg) 69 { 70 String s = createMessage(msg); 71 JOptionPane.showMessageDialog(null, s, title, JOptionPane.ERROR_MESSAGE); 72 } 73 74 76 83 public static boolean yesno(String msg) 84 { 85 String s = createMessage(msg); 86 int reply = JOptionPane.showConfirmDialog(null, s, title, JOptionPane.YES_NO_OPTION); 88 89 if(reply == JOptionPane.YES_OPTION) 90 return true; 91 92 return false; 93 } 94 95 97 private Reminder() 98 { 99 } 100 101 103 private static String createMessage(String s) 104 { 105 String location; 106 107 try 108 { 109 location = "\n\nCode Location: " + new CallerInfo(me).toString(); 110 } 111 catch(CallerInfoException e) 112 { 113 location = "\n\nUnknown code location"; 114 } 115 116 return preMessage + s + location; 117 } 118 119 121 private final static String title = "Temporary Code Reminder"; 122 private final static String preMessage = "***** DO NOT SHIP WITH THIS MESSAGE IN PLACE!!!! ******\n\n"; 123 private final static Object [] me = { new Reminder() }; 124 125 127 130 public static void main(String [] notUsed) 131 { 132 ReminderTester rt = new ReminderTester(); 133 rt.test(); 134 System.exit(0); 135 } 136 137 } 138 139 class ReminderTester 140 { 141 public void test() 142 { 143 Reminder.message("Here is Reminder.message()"); 144 boolean ret = Reminder.yesno("Here is Reminder.yesno(). Do you like it?"); 145 Reminder.message("You replied: " + (ret ? "yes" : "no")); 146 } 147 } 148 | Popular Tags |