Java Reference
In-Depth Information
private
private static
static final
final
long
long
serialVersionUID
=
1L
;
private
private
ResourceBundle rb
;
// Constructor
JOptionDemo
(
String s
) {
super
super
(
s
);
Container cp
=
getContentPane
();
cp
.
setLayout
(
new
new
FlowLayout
());
rb
=
ResourceBundle
.
getBundle
(
"Widgets"
);
JButton b
=
I18N
.
mkButton
(
rb
,
"getButton"
);
b
.
addActionListener
(
new
new
ActionListener
() {
public
public
void
void
actionPerformed
(
ActionEvent e
) {
JOptionPane
.
showMessageDialog
(
JOptionDemo
.
this
,
rb
.
getString
(
"dialog1.text"
),
rb
.
getString
(
"dialog1.title"
),
JOptionPane
.
INFORMATION_MESSAGE
);
}
});
cp
.
add
(
b
);
b
=
I18N
.
mkButton
(
rb
,
"goodbye"
);
b
.
addActionListener
(
new
new
ActionListener
() {
public
public
void
void
actionPerformed
(
ActionEvent e
) {
System
.
exit
(
0
);
}
});
cp
.
add
(
b
);
// the main window
setSize
(
200
,
150
);
pack
();
}
public
public static
void
main
(
String
[]
arg
) {
JOptionDemo x
=
new
static
void
new
JOptionDemo
(
"Testing 1 2 3..."
);
x
.
setVisible
(
true
true
);
}
}