Changeset 15845 in josm
- Timestamp:
- 2020-02-12T00:06:43+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/preferences
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/DefaultTabPreferenceSetting.java
r13431 r15845 49 49 this.tabpane = tabpane; 50 50 this.subSettingMap = tabpane != null ? new HashMap<>() : null; 51 if (tabpane != null) { 52 tabpane.addMouseWheelListener(new PreferenceTabbedPane.WheelListener(tabpane)); 53 } 51 54 } 52 55 -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r15844 r15845 79 79 * @author imi 80 80 */ 81 public final class PreferenceTabbedPane extends JTabbedPane implements MouseWheelListener,ExpertModeChangeListener, ChangeListener {81 public final class PreferenceTabbedPane extends JTabbedPane implements ExpertModeChangeListener, ChangeListener { 82 82 83 83 private final class PluginDownloadAfterTask implements Runnable { … … 446 446 public PreferenceTabbedPane() { 447 447 super(JTabbedPane.LEFT, JTabbedPane.SCROLL_TAB_LAYOUT); 448 super.addMouseWheelListener( this);448 super.addMouseWheelListener(new WheelListener(this)); 449 449 super.getModel().addChangeListener(this); 450 450 ExpertToggleAction.addExpertModeChangeListener(this); … … 578 578 * tab strip and scrolls one tab/down or up, selecting it immediately. 579 579 */ 580 @Override 581 public void mouseWheelMoved(MouseWheelEvent wev) { 582 // Ensure the cursor is over the tab strip 583 if (super.indexAtLocation(wev.getPoint().x, wev.getPoint().y) < 0) 584 return; 585 586 // Get currently selected tab 587 int newTab = super.getSelectedIndex() + wev.getWheelRotation(); 588 589 // Ensure the new tab index is sound 590 newTab = newTab < 0 ? 0 : newTab; 591 newTab = newTab >= super.getTabCount() ? super.getTabCount() - 1 : newTab; 592 593 // select new tab 594 super.setSelectedIndex(newTab); 580 static final class WheelListener implements MouseWheelListener { 581 582 final JTabbedPane tabbedPane; 583 584 WheelListener(JTabbedPane tabbedPane) { 585 this.tabbedPane = tabbedPane; 586 } 587 588 @Override 589 public void mouseWheelMoved(MouseWheelEvent wev) { 590 // Ensure the cursor is over the tab strip 591 if (tabbedPane.indexAtLocation(wev.getPoint().x, wev.getPoint().y) < 0) 592 return; 593 594 // Get currently selected tab && ensure the new tab index is sound 595 int newTab = Utils.clamp(tabbedPane.getSelectedIndex() + wev.getWheelRotation(), 596 0, tabbedPane.getTabCount() - 1); 597 598 tabbedPane.setSelectedIndex(newTab); 599 } 595 600 } 596 601
Note:
See TracChangeset
for help on using the changeset viewer.