/[svn]/jsampler/trunk/src/org/jsampler/HF.java
ViewVC logotype

Diff of /jsampler/trunk/src/org/jsampler/HF.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 910 by iliev, Mon Oct 10 16:03:12 2005 UTC revision 911 by iliev, Mon Aug 7 18:25:58 2006 UTC
# Line 40  import static org.jsampler.JSI18n.i18n; Line 40  import static org.jsampler.JSI18n.i18n;
40    
41    
42  /**  /**
43   *   * This class contains some helper function.
44   * @author Grigor Iliev   * @author Grigor Iliev
45   */   */
46  public class HF {  public class HF {
47  // GUI HELPER FUNCIONS  // GUI HELPER FUNCIONS
48            
49            /**
50             * Returns more meaningful, non-<code>null</code> message.
51             * @return More meaningful, non-<code>null</code> message.
52             */
53          public static String          public static String
54          getErrorMessage(Exception e) {          getErrorMessage(Exception e) {
55                  String msg = e.getMessage();                  String msg = e.getMessage();
# Line 58  public class HF { Line 63  public class HF {
63                  return msg;                  return msg;
64          }          }
65                    
66            /**
67             * Shows a dialog with the specified error message.
68             * @param msg The error message to be shown.
69             */
70          public static void          public static void
71          showErrorMessage(String msg) { showErrorMessage(msg, CC.getMainFrame()); }          showErrorMessage(String msg) { showErrorMessage(msg, CC.getMainFrame()); }
72                    
73            /**
74             * Shows a dialog with the specified error message.
75             * @param frame The parent <code>Frame</code> for the dialog.
76             * @param msg The error message to be shown.
77             */
78          public static void          public static void
79          showErrorMessage(String msg, Frame frame) {          showErrorMessage(String msg, Frame frame) {
80                  JOptionPane.showMessageDialog (                  JOptionPane.showMessageDialog (
# Line 70  public class HF { Line 84  public class HF {
84                  );                  );
85          }          }
86                    
87            /**
88             * Shows a dialog with the specified error message.
89             * @param dlg The parent <code>Dialog</code> from which the dialog is displayed.
90             * @param msg The error message to be shown.
91             */
92          public static void          public static void
93          showErrorMessage(String msg, Dialog dlg) {          showErrorMessage(String msg, Dialog dlg) {
94                  JOptionPane.showMessageDialog (                  JOptionPane.showMessageDialog (
# Line 79  public class HF { Line 98  public class HF {
98                  );                  );
99          }          }
100                    
101            /**
102             * Shows a dialog with error message obtained by {@link #getErrorMessage} method.
103             * @param e The <code>Exception</code> from which the error message is obtained.
104             */
105          public static void          public static void
106          showErrorMessage(Exception e) { showErrorMessage(e, CC.getMainFrame()); }          showErrorMessage(Exception e) { showErrorMessage(e, CC.getMainFrame()); }
107                    
108            /**
109             * Shows a dialog with error message obtained by {@link #getErrorMessage} method.
110             * @param e The <code>Exception</code> from which the error message is obtained.
111             * @param prefix The prefix to be added to the error message.
112             */
113            public static void
114            showErrorMessage(Exception e, String prefix) {
115                    showErrorMessage(e, CC.getMainFrame(), prefix);
116            }
117            
118            /**
119             * Shows a dialog with error message obtained by {@link #getErrorMessage} method.
120             * @param e The <code>Exception</code> from which the error message is obtained.
121             * @param frame The parent <code>Frame</code> for the dialog.
122             */
123          public static void          public static void
124          showErrorMessage(Exception e, Frame frame) {          showErrorMessage(Exception e, Frame frame) {
125                  String msg = getErrorMessage(e);                  showErrorMessage(e, frame, "");
126            }
127            
128            /**
129             * Shows a dialog with error message obtained by {@link #getErrorMessage} method.
130             * @param e The <code>Exception</code> from which the error message is obtained.
131             * @param frame The parent <code>Frame</code> for the dialog.
132             * @param prefix The prefix to be added to the error message.
133             */
134            public static void
135            showErrorMessage(Exception e, Frame frame, String prefix) {
136                    String msg = prefix + getErrorMessage(e);
137                                    
138                  CC.getLogger().log(Level.INFO, msg, e);                  CC.getLogger().log(Level.INFO, msg, e);
139                                                    
# Line 95  public class HF { Line 144  public class HF {
144                  );                  );
145          }          }
146                    
147            /**
148             * Shows a dialog with error message obtained by {@link #getErrorMessage} method.
149             * @param e The <code>Exception</code> from which the error message is obtained.
150             * @param dlg The parent <code>Dialog</code> from which the dialog is displayed.
151             */
152          public static void          public static void
153          showErrorMessage(Exception e, Dialog dlg) {          showErrorMessage(Exception e, Dialog dlg) {
154                  String msg = getErrorMessage(e);                  String msg = getErrorMessage(e);
# Line 110  public class HF { Line 164  public class HF {
164                    
165          /**          /**
166           * Brings up a question dialog with Yes, No options, empty title and the specified message.           * Brings up a question dialog with Yes, No options, empty title and the specified message.
167           *           * @param parent The parent <code>Component</code> for the dialog.
168             * @param message The message to display.
169           */           */
170          public static boolean          public static boolean
171          showYesNoDialog(Component parent, String message) {          showYesNoDialog(Component parent, String message) {
172                  return showYesNoDialog(parent, message, "");                  return showYesNoDialog(parent, message, "");
173          }          }
174                    
175            /**
176             * Brings up a question dialog with Yes, No options, empty title and the specified message.
177             * @param parent The parent <code>Component</code> for the dialog.
178             * @param message The message to display.
179             * @param title The dialog's title.
180             */
181          public static boolean          public static boolean
182          showYesNoDialog(Component parent, String message, String title) {          showYesNoDialog(Component parent, String message, String title) {
183                  Object[] options = { i18n.getButtonLabel("yes"), i18n.getButtonLabel("no") };                  Object[] options = { i18n.getButtonLabel("yes"), i18n.getButtonLabel("no") };
# Line 132  public class HF { Line 193  public class HF {
193                  return n == 0;                  return n == 0;
194          }          }
195                    
196            /**
197             * Sets the default font to be used in the GUI.
198             * @param fontName The name of the font to be used as default.
199             */
200          public static void          public static void
201          setUIDefaultFont(String fontName) {          setUIDefaultFont(String fontName) {
202                  if(fontName == null) return;                  if(fontName == null) return;

Legend:
Removed from v.910  
changed lines
  Added in v.911

  ViewVC Help
Powered by ViewVC