1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package p3j.gui.dialogs;
17
18 import java.awt.event.ActionEvent;
19 import java.awt.event.ActionListener;
20 import java.util.ArrayList;
21 import java.util.List;
22
23 import javax.swing.JButton;
24 import javax.swing.JDialog;
25
26
27
28
29
30
31
32 public abstract class ProjectionDialog extends JDialog {
33
34
35 private static final long serialVersionUID = -4217198597804149925L;
36
37
38 protected static final int DIALOG_HEIGHT = 150;
39
40
41 protected static final int DIALOG_WIDTH = 600;
42
43
44 private final JButton okButton = new JButton("OK");
45 {
46 okButton.addActionListener(new ActionListener() {
47 @Override
48 public void actionPerformed(ActionEvent e) {
49 okAction();
50 }
51 });
52 }
53
54
55 private final JButton cancelButton = new JButton("Cancel");
56 {
57 getCancelButton().addActionListener(new ActionListener() {
58 @Override
59 public void actionPerformed(ActionEvent e) {
60 setVisible(false);
61 }
62 });
63 }
64
65 private final List<JButton> buttons = new ArrayList<JButton>();
66 {
67 getButtons().add(getOkButton());
68 getButtons().add(getCancelButton());
69 }
70
71
72
73
74 protected abstract void okAction();
75
76 public List<JButton> getButtons() {
77 return buttons;
78 }
79
80 public JButton getOkButton() {
81 return okButton;
82 }
83
84 public JButton getCancelButton() {
85 return cancelButton;
86 }
87 }