1 package com.jsql.view.swing.tab.dnd;
2
3 import javax.swing.*;
4 import java.awt.*;
5
6 public class GhostGlassPane extends JComponent {
7
8 private DnDTabbedPane tabbedPane;
9
10 protected GhostGlassPane(DnDTabbedPane tabbedPane) {
11 this.tabbedPane = tabbedPane;
12 this.setOpaque(false);
13 }
14
15 @Override
16 protected void paintComponent(Graphics g) {
17 this.tabbedPane.getDropLineRect().ifPresent(rect -> {
18 Graphics2D g2 = (Graphics2D) g.create();
19 var r = SwingUtilities.convertRectangle(this.tabbedPane, rect, this);
20 g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .5f));
21 g2.setPaint(Color.RED);
22 g2.fill(r);
23 g2.dispose();
24 });
25 }
26
27 public void setTargetTabbedPane(DnDTabbedPane tab) {
28 this.tabbedPane = tab;
29 }
30 }