test/java/awt/Mixing/AWT_Mixing/FrameBorderCounter.java

Print this page




  46             }
  47         });
  48         EventQueue.invokeAndWait(new Runnable() {
  49             public void run() {
  50                 background = new Frame();
  51                 background.setBounds(100, 100, 300, 300);
  52                 background.addMouseListener(new MouseAdapter() {
  53                     @Override
  54                     public void mouseEntered(MouseEvent e) {
  55                         entered = e.getLocationOnScreen();
  56                         System.err.println("[ENTERED] : " + entered);
  57                     }
  58                 });
  59                 background.setVisible(true);
  60             }
  61         });
  62         EventQueue.invokeAndWait(new Runnable() {
  63             public void run() {
  64                 frame = new Frame("Frame");
  65                 frame.setBounds(200, 200, 100, 100);
  66                 frame.addWindowListener(new WindowAdapter() {
  67                     public void windowClosing(WindowEvent e) {
  68                         System.exit(0);
  69                     }
  70                 });
  71                 frame.setVisible(true);
  72             }
  73         });
  74         Thread.sleep(1000);
  75         EventQueue.invokeAndWait(new Runnable() {
  76             public void run() {
  77                 location = frame.getLocationOnScreen();
  78                 size = frame.getSize();
  79             }
  80         });
  81         int out = 20;
  82         for (int x = location.x + size.width - out; x <= location.x + size.width + out; ++x) {
  83             robot.mouseMove(x, location.y + size.height / 2);
  84             Thread.sleep(50);
  85         }
  86         System.err.println("[LOCATION] : " + location);
  87         System.err.println("[SIZE] : " + size);
  88         Thread.sleep(250);
  89         int shift = entered.x - location.x - size.width - 1;
  90         System.err.println("Done");


  46             }
  47         });
  48         EventQueue.invokeAndWait(new Runnable() {
  49             public void run() {
  50                 background = new Frame();
  51                 background.setBounds(100, 100, 300, 300);
  52                 background.addMouseListener(new MouseAdapter() {
  53                     @Override
  54                     public void mouseEntered(MouseEvent e) {
  55                         entered = e.getLocationOnScreen();
  56                         System.err.println("[ENTERED] : " + entered);
  57                     }
  58                 });
  59                 background.setVisible(true);
  60             }
  61         });
  62         EventQueue.invokeAndWait(new Runnable() {
  63             public void run() {
  64                 frame = new Frame("Frame");
  65                 frame.setBounds(200, 200, 100, 100);





  66                 frame.setVisible(true);
  67             }
  68         });
  69         Thread.sleep(1000);
  70         EventQueue.invokeAndWait(new Runnable() {
  71             public void run() {
  72                 location = frame.getLocationOnScreen();
  73                 size = frame.getSize();
  74             }
  75         });
  76         int out = 20;
  77         for (int x = location.x + size.width - out; x <= location.x + size.width + out; ++x) {
  78             robot.mouseMove(x, location.y + size.height / 2);
  79             Thread.sleep(50);
  80         }
  81         System.err.println("[LOCATION] : " + location);
  82         System.err.println("[SIZE] : " + size);
  83         Thread.sleep(250);
  84         int shift = entered.x - location.x - size.width - 1;
  85         System.err.println("Done");