DataContext (@NotNull Component component, int x, int y) { if (x < 0 || x >= component.getWidth() || y < 0 || y >= component.getHeight()) { throw new IllegalArgumentException("wrong point: x=" + x + "; y=" + y); } // Point inside JTabbedPane has special meaning. If point is inside tab bounds then // we construct DataContext by the component which corresponds to the (x, y) tab. if (component instanceof JTabbedPane tabbedPane) { int index = tabbedPane.getUI().tabForCoordinate(tabbedPane, x, y); return getDataContext(index != -1 ? tabbedPane.getComponentAt(index) : tabbedPane); } else { return getDataContext(component); } }