Java Reference
In-Depth Information
}
catch
catch
(
MessagingException me
) {
me
.
printStackTrace
();
while
while
((
me
= (
MessagingException
)
me
.
getNextException
()) !=
null
null
) {
me
.
printStackTrace
();
}
JOptionPane
.
showMessageDialog
(
null
null
,
"Mail Sending Error:\n"
+
me
.
toString
(),
"Error"
,
JOptionPane
.
ERROR_MESSAGE
);
}
catch
catch
(
Exception e
) {
JOptionPane
.
showMessageDialog
(
null
null
,
"Mail Sending Error:\n"
+
e
.
toString
(),
"Error"
,
JOptionPane
.
ERROR_MESSAGE
);
}
}
private
private
void
void
maybeKillParent
() {
iif
(
parent
==
null
null
)
return
;
iif
(
parent
instanceof
return
instanceof
Frame
) {
((
Frame
)
parent
).
setVisible
(
true
true
);
((
Frame
)
parent
).
dispose
();
}
iif
(
parent
instanceof
instanceof
JInternalFrame
) {
((
JInternalFrame
)
parent
).
setVisible
(
true
true
);
((
JInternalFrame
)
parent
).
dispose
();
}
}
/** Simple test case driver */
public
public static
static
void
void
main
(
String
[]
av
) {
final
final
JFrame jf
=
new
new
JFrame
(
"DarwinSys Compose Mail Tester"
);
System
.
getProperties
().
setProperty
(
"Mail.server"
,
"mailhost"
);
System
.
getProperties
().
setProperty
(
"Mail.address"
,
"nobody@home"
);
MailComposeBean sm
=
new
new
MailComposeBean
(
jf
,
"Test Mailer"
,
"spam-magnet@darwinsys.com"
,
500
,
400
);
sm
.
setSize
(
500
,
400
);
jf
.
getContentPane
().
add
(
sm
);
jf
.
setLocation
(
100
,
100
);
jf
.
setVisible
(
true
true
);
jf
.
addWindowListener
(
new
new
WindowAdapter
() {
public
void
windowClosing
(
WindowEvent e
) {
jf
.
setVisible
(
false
public
void
false
);
jf
.
dispose
();
System
.
exit
(
0
);