Changeset 11506 in josm for trunk/src/org


Ignore:
Timestamp:
2017-01-27T02:24:04+01:00 (3 years ago)
Author:
Don-vip
Message:

simplify MenuScroller

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MenuScroller.java

    r9078 r11506  
    4848    private final MenuScrollListener menuListener = new MenuScrollListener();
    4949    private final MouseWheelListener mouseWheelListener = new MouseScrollListener();
    50     private int interval;
    5150    private int topFixedCount;
    5251    private int firstIndex;
     
    260259        }
    261260
    262         upItem = new MenuScrollItem(MenuIcon.UP, -1);
    263         downItem = new MenuScrollItem(MenuIcon.DOWN, +1);
    264         setInterval(interval);
     261        upItem = new MenuScrollItem(MenuIcon.UP, -1, interval);
     262        downItem = new MenuScrollItem(MenuIcon.DOWN, +1, interval);
    265263        setTopFixedCount(topFixedCount);
    266264
     
    268266        menu.addPopupMenuListener(menuListener);
    269267        menu.addMouseWheelListener(mouseWheelListener);
    270     }
    271 
    272     /**
    273      * Returns the scroll interval in milliseconds
    274      *
    275      * @return the scroll interval in milliseconds
    276      */
    277     public int getInterval() {
    278         return interval;
    279     }
    280 
    281     /**
    282      * Sets the scroll interval in milliseconds
    283      *
    284      * @param interval the scroll interval in milliseconds
    285      * @throws IllegalArgumentException if interval is 0 or negative
    286      */
    287     public void setInterval(int interval) {
    288         if (interval <= 0) {
    289             throw new IllegalArgumentException("interval must be greater than 0");
    290         }
    291         upItem.setInterval(interval);
    292         downItem.setInterval(interval);
    293         this.interval = interval;
    294268    }
    295269
     
    445419        private final MenuScrollTimer timer;
    446420
    447         MenuScrollItem(MenuIcon icon, int increment) {
     421        MenuScrollItem(MenuIcon icon, int increment, int interval) {
    448422            setIcon(icon);
    449423            setDisabledIcon(icon);
    450424            timer = new MenuScrollTimer(increment, interval);
    451425            addChangeListener(this);
    452         }
    453 
    454         public void setInterval(int interval) {
    455             timer.setDelay(interval);
    456426        }
    457427
Note: See TracChangeset for help on using the changeset viewer.