I am trying to achieve the following
http://www.qksnap.com/i/3hunq/4ld0v/screenshot.png
Currently, I can draw rectangles on a translucent glass background using the following code:
protected void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g.setColor(Color.black); // black background g.fillRect(0, 0, frame.getWidth(), frame.getHeight()); g2.setColor(Color.GREEN.darker()); if (getRect() != null && isDrawing()) { g2.draw(getRect()); // draw our rectangle (simple Rectangle class) } g2.dispose(); }
Which works fine, however, I would like the area inside the rectangle to be completely transparent and the outside to be still dark, as in the screenshot above.
Any ideas?
source share