Package javax.swing

Examples of javax.swing.JWindow$AccessibleJWindow


        // (Don't use black, since a failed sample is sometimes black)
        final Color BACKGROUND = Color.GREEN;
        final Color FOREGROUND = Color.RED;
        back.setBackground(BACKGROUND);
        back.setLocation(X, Y);
        final JWindow front = new JWindow(root);
        front.getContentPane().setBackground(FOREGROUND);
        front.setLocation(X, Y);
        Area mask = new Area(new Rectangle(0, 0, W, H));
        mask.subtract(new Area(new Rectangle(W/4, H/4, W/2, H/2)));
        WindowUtils.setWindowMask(front, mask);
       
        front.addMouseListener(handler);
        front.addMouseMotionListener(handler);

        SwingUtilities.invokeAndWait(new Runnable() { public void run() {
            back.pack();
            back.setSize(new Dimension(W, H));
            back.setVisible(true);
            front.pack();
            front.setSize(new Dimension(W, H));
            front.setVisible(true);
        }});
       
        Point where = front.getLocationOnScreen();
        where.translate(W/8, H/8);
        Color sample = robot.getPixelColor(where.x, where.y);
        long start = System.currentTimeMillis();
        while (!sample.equals(FOREGROUND)) {
            SwingUtilities.invokeAndWait(new Runnable() { public void run() {
                front.toFront();
            }});
            Thread.sleep(10);
            if (System.currentTimeMillis() - start > 5000)
                fail("Timed out waiting for shaped window to appear, "
                     + "expected foreground color (sample="
                     + sample + " vs expected=" + FOREGROUND + ")");
            sample = robot.getPixelColor(where.x, where.y);
        }

        where = front.getLocationOnScreen();
        where.translate(W/2, H/2);
        sample = robot.getPixelColor(where.x, where.y);
        start = System.currentTimeMillis();
        while (!sample.equals(BACKGROUND)) {
            Thread.sleep(10);
View Full Code Here


    // Forcer not required on OSX
    if (Platform.isMac())
      return;

    Frame root = JOptionPane.getRootFrame();
    final JWindow w = new JWindow(root);
    w.getContentPane().add(new JLabel(getName()));
    final Rectangle mask = new Rectangle(0, 0, 10, 10);
    SwingUtilities.invokeAndWait(new Runnable() {
      public void run() {
        w.pack();
        WindowUtils.setWindowMask(w, mask);
        w.setVisible(true);
      }
    });
    try {
      Window[] owned = w.getOwnedWindows();
      WeakReference ref = null;
      for (int i = 0; i < owned.length; i++) {
        if (owned[i].getClass().getName().indexOf("Heavy") != -1) {
          ref = new WeakReference(owned[i]);
          break;
        }
      }
      owned = null;
      assertNotNull("Forcer not found", ref);
      SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
          WindowUtils.setWindowMask(w, WindowUtils.MASK_NONE);
        }
      });
      System.gc();
      long start = System.currentTimeMillis();
      while (ref.get() != null) {
        Thread.sleep(10);
        System.gc();
        if (System.currentTimeMillis() - start > 5000)
          fail("Timed out waiting for forcer to be GC'd");
      }
      assertNull("Forcer not GC'd", ref.get());
    } finally {
      w.dispose();
    }
  }
View Full Code Here

    public void run() {
        // Must find a graphics configuration with a depth of 32 bits
        GraphicsConfiguration gconfig = WindowUtils.getAlphaCompatibleGraphicsConfiguration();
        frame = new JFrame("Alpha Mask Demo");
        alphaWindow = new JWindow(frame, gconfig);
        icon = new JLabel();
        icon.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        alphaWindow.getContentPane().add(icon);
        JButton quit = new JButton("Quit");
        JLabel label = new JLabel("Drag this window by its image");
View Full Code Here

   
    public void run() {
        // Must find a graphics configuration with a depth of 32 bits
        GraphicsConfiguration gconfig = WindowUtils.getAlphaCompatibleGraphicsConfiguration();
        frame = new JFrame("Alpha Mask Demo");
        alphaWindow = new JWindow(frame, gconfig);
        MouseInputAdapter handler = new MouseInputAdapter() {
            private Point offset;
            public void mousePressed(MouseEvent e) {
                if (SwingUtilities.isLeftMouseButton(e))
                    offset = e.getPoint();
View Full Code Here

TOP

Related Classes of javax.swing.JWindow$AccessibleJWindow

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.