JTabbedPane - 如何使用鼠标滚轮滚动(不是 select)选项卡 (SCROLL_TAB_LAYOUT)

JTabbedPane - How to scroll (not select) tabs with mouse wheel (SCROLL_TAB_LAYOUT)

当 space 受限时,选项卡将显示在滚动窗格中,并出现两个小箭头按钮。我想用鼠标滚轮来操作这些按钮。

中有一个很好的解决方案,但它实际上选择了选项卡。我只想滚动它们,而不更改选择。

如何获得这些按钮或相关操作?

(我正在使用 Nimbus LaF,如果这很重要的话。)

刚找到! https://java-swing-tips.blogspot.co.at/2008/04/drag-and-drop-tabs-in-jtabbedpane.html 的 DnDTabbedPane 中的拖放代码有这个非常好的方法:

private void clickArrowButton(String actionKey) {
    ActionMap map = getActionMap();
    if (map != null) {
        Action action = map.get(actionKey);
        if (action != null && action.isEnabled()) {
            action.actionPerformed(new ActionEvent(
                    this, ActionEvent.ACTION_PERFORMED, null, 0, 0));
        }
    }
}

所以我只想说:

    addMouseWheelListener(new MouseWheelListener() {
        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
            if (e.getWheelRotation() > 0) {
                clickArrowButton("scrollTabsBackwardAction");
            } else {
                clickArrowButton("scrollTabsForwardAction");
            }
        }
    });