public OSXMaskingContentPane(Component oldContent) { super(new BorderLayout()); if (oldContent != null) { add(oldContent, BorderLayout.CENTER); } }
@Override public void paint(Graphics graphics) { Graphics2D g = (Graphics2D)graphics.create(); g.setComposite(AlphaComposite.Clear); g.fillRect(0, 0, getWidth(), getHeight()); g.dispose(); if (shape != null) { g = (Graphics2D)graphics.create(); g.setClip(shape); super.paint(g); g.dispose(); } else { super.paint(graphics); } } }
private OSXMaskingContentPane installMaskingPane(Window w) { OSXMaskingContentPane content; if (w instanceof RootPaneContainer) { // TODO: replace layered pane instead? final RootPaneContainer rpc = (RootPaneContainer)w; Container oldContent = rpc.getContentPane(); if (oldContent instanceof OSXMaskingContentPane) { content = (OSXMaskingContentPane)oldContent; } else { content = new OSXMaskingContentPane(oldContent); // TODO: listen for content pane changes rpc.setContentPane(content); } } else { Component oldContent = w.getComponentCount() > 0 ? w.getComponent(0) : null; if (oldContent instanceof OSXMaskingContentPane) { content = (OSXMaskingContentPane)oldContent; } else { content = new OSXMaskingContentPane(oldContent); w.add(content); } } return content; }
private OSXMaskingContentPane installMaskingPane(Window w) { OSXMaskingContentPane content; if (w instanceof RootPaneContainer) { // TODO: replace layered pane instead? final RootPaneContainer rpc = (RootPaneContainer)w; Container oldContent = rpc.getContentPane(); if (oldContent instanceof OSXMaskingContentPane) { content = (OSXMaskingContentPane)oldContent; } else { content = new OSXMaskingContentPane(oldContent); // TODO: listen for content pane changes rpc.setContentPane(content); } } else { Component oldContent = w.getComponentCount() > 0 ? w.getComponent(0) : null; if (oldContent instanceof OSXMaskingContentPane) { content = (OSXMaskingContentPane)oldContent; } else { content = new OSXMaskingContentPane(oldContent); w.add(content); } } return content; }
public void paint(Graphics graphics) { Graphics2D g = (Graphics2D)graphics.create(); g.setComposite(AlphaComposite.Clear); g.fillRect(0, 0, getWidth(), getHeight()); g.dispose(); if (shape != null) { g = (Graphics2D)graphics.create(); g.setClip(shape); super.paint(g); g.dispose(); } else { super.paint(graphics); } } }
public void setMask(Shape shape) { this.shape = shape; repaint(); }
public void setWindowMask(Component c, final Shape shape) { if (c instanceof Window) { Window w = (Window)c; OSXMaskingContentPane content = installMaskingPane(w); content.setMask(shape); setBackgroundTransparent(w, shape != MASK_NONE, "setWindowMask"); } else { // not yet implemented } }
public OSXMaskingContentPane(Component oldContent) { super(new BorderLayout()); if (oldContent != null) { add(oldContent, BorderLayout.CENTER); } }
public void setMask(Shape shape) { this.shape = shape; repaint(); }
@Override public void setWindowMask(Component c, final Shape shape) { if (c instanceof Window) { Window w = (Window)c; OSXMaskingContentPane content = installMaskingPane(w); content.setMask(shape); setBackgroundTransparent(w, shape != MASK_NONE, "setWindowMask"); } else { // not yet implemented } }