-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAboutDialog.java
More file actions
33 lines (23 loc) · 791 Bytes
/
AboutDialog.java
File metadata and controls
33 lines (23 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package dialog;
import javax.swing.*;
import java.awt.*;
/**
* A sample modal dialog that displays a message and waits for the user to click the OK button.
*/
public class AboutDialog extends JDialog {
public AboutDialog(JFrame owner) {
super(owner, "About DialogTest", true);
// add HTML label to center
add(new JLabel(
"<html><h1><i>Core Java</i></h1><hr>By Cay Horstmann</html>"),
BorderLayout.CENTER);
// OK button closes the dialog
JButton ok = new JButton("OK");
ok.addActionListener(event -> setVisible(false));
// add OK button to southern border
JPanel panel = new JPanel();
panel.add(ok);
add(panel, BorderLayout.SOUTH);
pack();
}
}