void (MouseEvent e) { if (e.isPopupTrigger()) { // Popup doesn't activate clicked tab. showPopup(e.getX(), e.getY()); return; } if (!e.isShiftDown() && (InputEvent.BUTTON1_MASK & e.getModifiers()) > 0) { // RightClick without Shift modifiers just select tab if (MouseEvent.MOUSE_RELEASED == e.getID()) { TabbedPaneUI ui = getUI(); int index = ui.tabForCoordinate(this, e.getX(), e.getY()); if (index != -1) { setSelectedIndex(index); // Always request a focus for tab component when user clicks on tab header. IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown( () -> IdeFocusManager.getGlobalInstance().requestFocus(MyTabbedPaneWrapper.this.getComponent(), true)); } hideMenu(); } } else if (e.isShiftDown() && (InputEvent.BUTTON1_MASK & e.getModifiers()) > 0) { // Shift+LeftClick closes the tab if (MouseEvent.MOUSE_RELEASED == e.getID()) { closeTabAt(e.getX(), e.getY()); hideMenu(); } } else if ((InputEvent.BUTTON2_MASK & e.getModifiers()) > 0) { // MouseWheelClick closes the tab if (MouseEvent.MOUSE_RELEASED == e.getID()) { closeTabAt(e.getX(), e.getY()); hideMenu(); } } else if ((InputEvent.BUTTON3_MASK & e.getModifiers()) > 0 && SystemInfo.isWindows) { // Right mouse button doesn't activate tab } else { super.processMouseEvent(e); } }