Changeset 2028 in josm for trunk/src/org
- Timestamp:
- 2009-09-02T22:01:39+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
r2017 r2028 7 7 import java.awt.GridBagLayout; 8 8 import java.awt.ScrollPane; 9 import java.awt.event.MouseWheelEvent; 10 import java.awt.event.MouseWheelListener; 9 11 import java.util.ArrayList; 10 12 import java.util.Collection; … … 33 35 * @author imi 34 36 */ 35 public class PreferenceDialog extends JTabbedPane {37 public class PreferenceDialog extends JTabbedPane implements MouseWheelListener { 36 38 37 39 private final static Collection<PreferenceSettingFactory> settingsFactory = new LinkedList<PreferenceSettingFactory>(); … … 116 118 public PreferenceDialog() { 117 119 super(JTabbedPane.LEFT, JTabbedPane.SCROLL_TAB_LAYOUT); 120 121 super.addMouseWheelListener(this); 118 122 119 123 for (PreferenceSettingFactory factory:settingsFactory) { … … 174 178 settingsFactory.add(new AdvancedPreference.Factory()); 175 179 } 180 181 /** 182 * This mouse wheel listener reacts when a scroll is carried out over the 183 * tab strip and scrolls one tab/down or up, selecting it immediately. 184 */ 185 public void mouseWheelMoved(MouseWheelEvent wev) { 186 // Ensure the cursor is over the tab strip 187 if(super.indexAtLocation(wev.getPoint().x, wev.getPoint().y) < 0) 188 return; 189 190 // Get currently selected tab 191 int newTab = super.getSelectedIndex() + wev.getWheelRotation(); 192 193 // Ensure the new tab index is sound 194 newTab = newTab < 0 ? 0 : newTab; 195 newTab = newTab >= super.getTabCount() ? super.getTabCount() - 1 : newTab; 196 197 // select new tab 198 super.setSelectedIndex(newTab); 199 } 176 200 }
Note:
See TracChangeset
for help on using the changeset viewer.