< prev index next >

test/jdk/java/awt/Modal/ToBack/ToBackDDFTest.java

Print this page




  45     private ToBackDDFTest(Dialog.ModalityType modType,
  46                           boolean             modal) throws Exception {
  47         modalityType = modType;
  48         setModal = modal;
  49 
  50         robot = new ExtendedRobot();
  51         EventQueue.invokeLater(this::createGUI);
  52     }
  53 
  54     public ToBackDDFTest(Dialog.ModalityType modalityType) throws Exception {
  55         this(modalityType, false);
  56     }
  57 
  58     public ToBackDDFTest(boolean modal) throws Exception { this(null, modal); }
  59 
  60     private void createGUI() {
  61 
  62         hiddenFrame = new Frame();
  63         leftDialog = new TestDialog(hiddenFrame);
  64         leftDialog.setLocation(50, 50);

  65         leftDialog.setBackground(Color.BLUE);
  66         leftDialog.setVisible(true);
  67 
  68         dialog = new CustomDialog(leftDialog);
  69 
  70         if (modalityType == null) {
  71             dialog.setModal(setModal);
  72             modalityType = dialog.getModalityType();
  73         } else if (modalityType != null) {
  74             dialog.setModalityType(modalityType);
  75         }
  76 
  77         dialog.setBackground(Color.WHITE);
  78         dialog.setLocation(150, 50);

  79 
  80         rightFrame = new TestFrame();
  81         rightFrame.setLocation(250, 50);

  82         rightFrame.setBackground(Color.RED);
  83 
  84         if (modalityType == Dialog.ModalityType.APPLICATION_MODAL) {
  85             rightFrame.setModalExclusionType(
  86                 Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
  87         } else if (modalityType == Dialog.ModalityType.TOOLKIT_MODAL) {
  88             rightFrame.setModalExclusionType(
  89                 Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
  90         }
  91 
  92         dialog.setVisible(true);
  93     }
  94 
  95     private void checkLeftDialogIsOverlapped(String msg) {
  96 
  97         Point p = leftDialog.getLocationOnScreen();
  98         int x = p.x + (int)(leftDialog.getWidth()  * 0.9);
  99         int y = p.y + (int)(leftDialog.getHeight() * 0.9);
 100         boolean f = robot.getPixelColor(x, y).equals(leftDialog.getBackground());
 101         assertFalse(f, msg);




  45     private ToBackDDFTest(Dialog.ModalityType modType,
  46                           boolean             modal) throws Exception {
  47         modalityType = modType;
  48         setModal = modal;
  49 
  50         robot = new ExtendedRobot();
  51         EventQueue.invokeLater(this::createGUI);
  52     }
  53 
  54     public ToBackDDFTest(Dialog.ModalityType modalityType) throws Exception {
  55         this(modalityType, false);
  56     }
  57 
  58     public ToBackDDFTest(boolean modal) throws Exception { this(null, modal); }
  59 
  60     private void createGUI() {
  61 
  62         hiddenFrame = new Frame();
  63         leftDialog = new TestDialog(hiddenFrame);
  64         leftDialog.setLocation(50, 50);
  65         leftDialog.setResizable(false);
  66         leftDialog.setBackground(Color.BLUE);
  67         leftDialog.setVisible(true);
  68 
  69         dialog = new CustomDialog(leftDialog);
  70 
  71         if (modalityType == null) {
  72             dialog.setModal(setModal);
  73             modalityType = dialog.getModalityType();
  74         } else if (modalityType != null) {
  75             dialog.setModalityType(modalityType);
  76         }
  77 
  78         dialog.setBackground(Color.WHITE);
  79         dialog.setLocation(150, 50);
  80         dialog.setResizable(false);
  81 
  82         rightFrame = new TestFrame();
  83         rightFrame.setLocation(250, 50);
  84         rightFrame.setResizable(false);
  85         rightFrame.setBackground(Color.RED);
  86 
  87         if (modalityType == Dialog.ModalityType.APPLICATION_MODAL) {
  88             rightFrame.setModalExclusionType(
  89                 Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
  90         } else if (modalityType == Dialog.ModalityType.TOOLKIT_MODAL) {
  91             rightFrame.setModalExclusionType(
  92                 Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
  93         }
  94 
  95         dialog.setVisible(true);
  96     }
  97 
  98     private void checkLeftDialogIsOverlapped(String msg) {
  99 
 100         Point p = leftDialog.getLocationOnScreen();
 101         int x = p.x + (int)(leftDialog.getWidth()  * 0.9);
 102         int y = p.y + (int)(leftDialog.getHeight() * 0.9);
 103         boolean f = robot.getPixelColor(x, y).equals(leftDialog.getBackground());
 104         assertFalse(f, msg);


< prev index next >