|
@@ -44,7 +44,7 @@ public class StandardDialog extends JDialog {
|
44
|
44
|
/** Serial version UID. */
|
45
|
45
|
private static final long serialVersionUID = 1;
|
46
|
46
|
/** Parent window. */
|
47
|
|
- private final Window owner;
|
|
47
|
+ private Window owner;
|
48
|
48
|
/** The OK button for this frame. */
|
49
|
49
|
private JButton okButton;
|
50
|
50
|
/** The cancel button for this frame. */
|
|
@@ -84,20 +84,23 @@ public class StandardDialog extends JDialog {
|
84
|
84
|
}
|
85
|
85
|
|
86
|
86
|
/**
|
87
|
|
- * Displays the dialog centering on the parent window.
|
|
87
|
+ * Displays the dialog if it is not visible, otherwise requests focus.
|
88
|
88
|
*/
|
89
|
|
- public void display() {
|
90
|
|
- display(owner);
|
|
89
|
+ public void displayOrRequestFocus() {
|
|
90
|
+ displayOrRequestFocus(owner);
|
91
|
91
|
}
|
92
|
92
|
|
93
|
93
|
/**
|
94
|
|
- * Displays the dialog if it is not visible, otherwise requests focus.
|
|
94
|
+ * Displays the dialog if it is not visible, otherwise requests focus. The parent window will
|
|
95
|
+ * only be changed if the dialog has not been displayed.
|
|
96
|
+ *
|
|
97
|
+ * @param parent Parent window
|
95
|
98
|
*/
|
96
|
|
- public void displayOrRequestFocus() {
|
|
99
|
+ public void displayOrRequestFocus(final Window parent) {
|
97
|
100
|
if (isVisible()) {
|
98
|
101
|
requestFocus();
|
99
|
102
|
} else {
|
100
|
|
- display();
|
|
103
|
+ display(parent);
|
101
|
104
|
}
|
102
|
105
|
}
|
103
|
106
|
|
|
@@ -106,7 +109,15 @@ public class StandardDialog extends JDialog {
|
106
|
109
|
*
|
107
|
110
|
* @param owner Window to center on
|
108
|
111
|
*/
|
109
|
|
- public void display(final Component owner) {
|
|
112
|
+ public void display(final Window owner) {
|
|
113
|
+ this.owner = owner;
|
|
114
|
+ display();
|
|
115
|
+ }
|
|
116
|
+
|
|
117
|
+ /**
|
|
118
|
+ * Displays the dialog centering on the parent window.
|
|
119
|
+ */
|
|
120
|
+ public void display() {
|
110
|
121
|
if (isVisible()) {
|
111
|
122
|
return;
|
112
|
123
|
}
|
|
@@ -146,7 +157,7 @@ public class StandardDialog extends JDialog {
|
146
|
157
|
/** {@inheritDoc} */
|
147
|
158
|
@Override
|
148
|
159
|
public void run() {
|
149
|
|
- display(owner);
|
|
160
|
+ display();
|
150
|
161
|
addWindowListener(new WindowAdapter() {
|
151
|
162
|
@Override
|
152
|
163
|
public void windowClosed(final WindowEvent e) {
|
|
@@ -174,7 +185,7 @@ public class StandardDialog extends JDialog {
|
174
|
185
|
*
|
175
|
186
|
* @return Parent window or null
|
176
|
187
|
*/
|
177
|
|
- public Window getParentWindow() {
|
|
188
|
+ public Component getParentWindow() {
|
178
|
189
|
return owner;
|
179
|
190
|
}
|
180
|
191
|
|