01: package org.uispec4j.interception;
02:
03: import org.uispec4j.Trigger;
04:
05: import javax.swing.*;
06: import java.awt.event.ActionEvent;
07:
08: public abstract class WindowInterceptorTestCase extends
09: InterceptionTestCase {
10: protected Trigger getShowFirstDialogTrigger() {
11: return new Trigger() {
12: public void run() throws Exception {
13: JDialog firstDialog = createDialogs();
14: logger.log("trigger");
15: firstDialog.show();
16: }
17: };
18: }
19:
20: private JDialog createDialogs() {
21: final JFrame frame = new JFrame();
22:
23: final JDialog firstDialog = new JDialog(frame, "first dialog",
24: true);
25: addHideButton(firstDialog, "Dispose");
26:
27: JDialog secondDialog = new JDialog(frame, "second dialog", true);
28: addShowDialogAndCloseButton(firstDialog, "OK", secondDialog);
29: addHideButton(secondDialog, "Dispose");
30:
31: JDialog thirdDialog = new JDialog(frame, "third dialog", true);
32: addHideButton(thirdDialog, "Dispose");
33: addShowDialogAndCloseButton(secondDialog, "OK", thirdDialog);
34: return firstDialog;
35: }
36:
37: protected static class ShowDialogAction extends AbstractAction {
38: private boolean modal;
39:
40: public ShowDialogAction(boolean modal) {
41: super ("Run");
42: this .modal = modal;
43: }
44:
45: public void actionPerformed(ActionEvent e) {
46: JDialog dialog = new JDialog();
47: dialog.setModal(modal);
48: dialog.setTitle("MyDialog");
49: dialog.show();
50: }
51: }
52: }
|