// Note: Doesn't show anything if are is not completely in allowed bounds static JWindow freeFloatingAnimation(S imageID, int x, int y, double seconds) { ret disposeWindowAfter(iround(seconds*1000), freeFloatingAnimation(imageID, x, y)); } static JWindow freeFloatingAnimation(final S imageID, final int x, final int y) { ret (JWindow) swingAndWait(func { JLabel label = new JLabel(imageIcon(imageID)); label.setOpaque(false); new JWindow w; w.setLocation(x, y); w.add(label); // add it to get appropriate size through pack() w.pack(); Rectangle maxBounds = maxWindowBounds(); Rectangle r = w.getBounds(); if (!maxBounds.contains(r)) null; /*w.setLocation( max(0, min(x, maxBounds.x+maxBounds.width-w.getWidth())), max(0, min(y, maxBounds.y+maxBounds.height-w.getHeight())));*/ Rectangle r2 = intersectWithScreen(r); BufferedImage background = shootScreen2(r2); //w.setLayout(null); w.remove(label); new JLayeredPane layeredPane; Rectangle bounds = new Rectangle(0, 0, w.getContentPane().getWidth(), w.getContentPane().getHeight()); w.add(layeredPane); JLabel lBackground = new JLabel(imageIcon(background)); lBackground.setBounds(0, 0, r2.width, r2.height); layeredPane.add(lBackground, boxed(1)); label.setBounds(bounds); layeredPane.add(label, new Int(2)); revalidate(w); w.setAlwaysOnTop(true); w.setVisible(true); ret w; }); }