--- jsampler/trunk/src/org/jsampler/HF.java 2006/08/07 18:01:57 910
+++ jsampler/trunk/src/org/jsampler/HF.java 2006/08/07 18:25:58 911
@@ -40,11 +40,16 @@
/**
- *
+ * This class contains some helper function.
* @author Grigor Iliev
*/
public class HF {
// GUI HELPER FUNCIONS
+
+ /**
+ * Returns more meaningful, non-null
message.
+ * @return More meaningful, non-null
message.
+ */
public static String
getErrorMessage(Exception e) {
String msg = e.getMessage();
@@ -58,9 +63,18 @@
return msg;
}
+ /**
+ * Shows a dialog with the specified error message.
+ * @param msg The error message to be shown.
+ */
public static void
showErrorMessage(String msg) { showErrorMessage(msg, CC.getMainFrame()); }
+ /**
+ * Shows a dialog with the specified error message.
+ * @param frame The parent Frame
for the dialog.
+ * @param msg The error message to be shown.
+ */
public static void
showErrorMessage(String msg, Frame frame) {
JOptionPane.showMessageDialog (
@@ -70,6 +84,11 @@
);
}
+ /**
+ * Shows a dialog with the specified error message.
+ * @param dlg The parent Dialog
from which the dialog is displayed.
+ * @param msg The error message to be shown.
+ */
public static void
showErrorMessage(String msg, Dialog dlg) {
JOptionPane.showMessageDialog (
@@ -79,12 +98,42 @@
);
}
+ /**
+ * Shows a dialog with error message obtained by {@link #getErrorMessage} method.
+ * @param e The Exception
from which the error message is obtained.
+ */
public static void
showErrorMessage(Exception e) { showErrorMessage(e, CC.getMainFrame()); }
+ /**
+ * Shows a dialog with error message obtained by {@link #getErrorMessage} method.
+ * @param e The Exception
from which the error message is obtained.
+ * @param prefix The prefix to be added to the error message.
+ */
+ public static void
+ showErrorMessage(Exception e, String prefix) {
+ showErrorMessage(e, CC.getMainFrame(), prefix);
+ }
+
+ /**
+ * Shows a dialog with error message obtained by {@link #getErrorMessage} method.
+ * @param e The Exception
from which the error message is obtained.
+ * @param frame The parent Frame
for the dialog.
+ */
public static void
showErrorMessage(Exception e, Frame frame) {
- String msg = getErrorMessage(e);
+ showErrorMessage(e, frame, "");
+ }
+
+ /**
+ * Shows a dialog with error message obtained by {@link #getErrorMessage} method.
+ * @param e The Exception
from which the error message is obtained.
+ * @param frame The parent Frame
for the dialog.
+ * @param prefix The prefix to be added to the error message.
+ */
+ public static void
+ showErrorMessage(Exception e, Frame frame, String prefix) {
+ String msg = prefix + getErrorMessage(e);
CC.getLogger().log(Level.INFO, msg, e);
@@ -95,6 +144,11 @@
);
}
+ /**
+ * Shows a dialog with error message obtained by {@link #getErrorMessage} method.
+ * @param e The Exception
from which the error message is obtained.
+ * @param dlg The parent Dialog
from which the dialog is displayed.
+ */
public static void
showErrorMessage(Exception e, Dialog dlg) {
String msg = getErrorMessage(e);
@@ -110,13 +164,20 @@
/**
* Brings up a question dialog with Yes, No options, empty title and the specified message.
- *
+ * @param parent The parent Component
for the dialog.
+ * @param message The message to display.
*/
public static boolean
showYesNoDialog(Component parent, String message) {
return showYesNoDialog(parent, message, "");
}
+ /**
+ * Brings up a question dialog with Yes, No options, empty title and the specified message.
+ * @param parent The parent Component
for the dialog.
+ * @param message The message to display.
+ * @param title The dialog's title.
+ */
public static boolean
showYesNoDialog(Component parent, String message, String title) {
Object[] options = { i18n.getButtonLabel("yes"), i18n.getButtonLabel("no") };
@@ -132,6 +193,10 @@
return n == 0;
}
+ /**
+ * Sets the default font to be used in the GUI.
+ * @param fontName The name of the font to be used as default.
+ */
public static void
setUIDefaultFont(String fontName) {
if(fontName == null) return;