Java Reference
In-Depth Information
SQLException sexc
= (
SQLException
)
theExc
;
message
+=
"; code="
+
sexc
.
getErrorCode
();
next
=
sexc
.
getNextException
();
}
else
else
{
next
=
theExc
.
getCause
();
// Comment out if < JDK 1.4
}
String
[]
choices
=
next
!=
null
null
?
choicesMore
:
choicesNoMore
;
/* Show the Dialog! */
int
int
response
=
JOptionPane
.
showOptionDialog
(
parent
,
message
,
className
,
// title
JOptionPane
.
YES_NO_CANCEL_OPTION
,
// icontType
JOptionPane
.
ERROR_MESSAGE
,
// messageType
null
null
,
// icon
choices
,
// options
choices
[
0
]
// default
);
iif
(
response
==
0
)
// "OK"
return
;
iif
(
response
==
1
) {
// "Details"
// show ANOTHER JDialog with a JTextArea of printStackTrace();
iif
(
detailsDialog
==
null
return
null
)
// first time, lazy creation
detailsDialog
=
new
new
DetailsDialog
((
JFrame
)
parent
);
detailsDialog
.
showStackTrace
(
theExc
);
}
// else resp = 2, "Next", let it fall through:
theExc
=
next
;
}
while
while
(
next
!=
null
null
);
}
/** JDialog class to display the details of an Exception */
protected
protected static
static class
class
DetailsDialog
DetailsDialog
extends
extends
JDialog
{
private
private static
static final
final
long
long
serialVersionUID
= -
4779441441693785664L
;
JButton ok
;
JTextArea text
;
/** Construct a DetailsDialog given a parent (Frame/JFrame) */
DetailsDialog
(
JFrame parent
) {
super
super
(
parent
);
Container cp
=
getContentPane
();