Package org.openstreetmap.josm.gui
Class MenuScroller
java.lang.Object
org.openstreetmap.josm.gui.MenuScroller
A class that provides scrolling capabilities to a long menu dropdown or
popup menu. A number of items can optionally be frozen at the top of the menu.
Implementation note: The default scrolling interval is 150 milliseconds.
- Since:
- 4593
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enumprivate classprivate final classprivate classprivate final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate final MenuScroller.MenuScrollItemprivate intprivate JPopupMenuprivate Component[]private final MenuScroller.MenuScrollListenerprivate final MouseWheelListenerprivate intprivate final MenuScroller.MenuScrollItem -
Constructor Summary
ConstructorsConstructorDescriptionMenuScroller(JMenu menu) Constructs aMenuScrollerthat scrolls a menu with the default scrolling interval.MenuScroller(JMenu menu, int interval) Constructs aMenuScrollerthat scrolls a menu with the specified scrolling interval.MenuScroller(JMenu menu, int interval, int topFixedCount) Constructs aMenuScrollerthat scrolls a menu with the specified scrolling interval, and the specified numbers of items fixed at the top of the menu.MenuScroller(JPopupMenu menu) Constructs aMenuScrollerthat scrolls a popup menu with the default scrolling interval.MenuScroller(JPopupMenu menu, int interval) Constructs aMenuScrollerthat scrolls a popup menu with the specified scrolling interval.MenuScroller(JPopupMenu menu, int interval, int topFixedCount) Constructs aMenuScrollerthat scrolls a popup menu with the specified scrolling interval, and the specified numbers of items fixed at the top of the popup menu. -
Method Summary
Modifier and TypeMethodDescriptionprivate intcomputeScrollCount(int startIndex) voiddispose()Removes this MenuScroller from the associated menu and restores the default behavior of the menu.intReturns the number of items fixed at the top of the menu or popup menu.private voidstatic MenuScrollersetScrollerFor(JMenu menu) Registers a menu to be scrolled with the default scrolling interval.static MenuScrollersetScrollerFor(JMenu menu, int interval) Registers a menu to be scrolled, with the specified scrolling interval.static MenuScrollersetScrollerFor(JMenu menu, int interval, int topFixedCount) Registers a menu to be scrolled, with the specified scrolling interval, and the specified numbers of items fixed at the top of the menu.static MenuScrollersetScrollerFor(JPopupMenu menu) Registers a popup menu to be scrolled with the default scrolling interval.static MenuScrollersetScrollerFor(JPopupMenu menu, int interval) Registers a popup menu to be scrolled, with the specified scrolling interval.static MenuScrollersetScrollerFor(JPopupMenu menu, int interval, int topFixedCount) Registers a popup menu to be scrolled, with the specified scrolling interval, and the specified numbers of items fixed at the top of the popup menu.voidsetTopFixedCount(int topFixedCount) Sets the number of items to fix at the top of the menu or popup menu.
-
Field Details
-
upItem
-
downItem
-
mouseWheelListener
-
topFixedCount
-
firstIndex
-
ARROW_ICON_HEIGHT
- See Also:
-
Constructor Details
-
MenuScroller
Constructs aMenuScrollerthat scrolls a menu with the default scrolling interval.- Parameters:
menu- the menu- Throws:
IllegalArgumentException- if scrollCount is 0 or negative
-
MenuScroller
Constructs aMenuScrollerthat scrolls a popup menu with the default scrolling interval.- Parameters:
menu- the popup menu- Throws:
IllegalArgumentException- if scrollCount is 0 or negative
-
MenuScroller
Constructs aMenuScrollerthat scrolls a menu with the specified scrolling interval.- Parameters:
menu- the menuinterval- the scroll interval, in milliseconds- Throws:
IllegalArgumentException- if scrollCount or interval is 0 or negative- Since:
- 7463
-
MenuScroller
Constructs aMenuScrollerthat scrolls a popup menu with the specified scrolling interval.- Parameters:
menu- the popup menuinterval- the scroll interval, in milliseconds- Throws:
IllegalArgumentException- if scrollCount or interval is 0 or negative- Since:
- 7463
-
MenuScroller
Constructs aMenuScrollerthat scrolls a menu with the specified scrolling interval, and the specified numbers of items fixed at the top of the menu.- Parameters:
menu- the menuinterval- the scroll interval, in millisecondstopFixedCount- the number of items to fix at the top. May be 0- Throws:
IllegalArgumentException- if scrollCount or interval is 0 or negative or if topFixedCount is negative- Since:
- 7463
-
MenuScroller
Constructs aMenuScrollerthat scrolls a popup menu with the specified scrolling interval, and the specified numbers of items fixed at the top of the popup menu.- Parameters:
menu- the popup menuinterval- the scroll interval, in millisecondstopFixedCount- the number of items to fix at the top. May be 0- Throws:
IllegalArgumentException- if scrollCount or interval is 0 or negative or if topFixedCount is negative- Since:
- 7463
-
-
Method Details
-
computeScrollCount
-
setScrollerFor
Registers a menu to be scrolled with the default scrolling interval.- Parameters:
menu- the menu- Returns:
- the MenuScroller
-
setScrollerFor
Registers a popup menu to be scrolled with the default scrolling interval.- Parameters:
menu- the popup menu- Returns:
- the MenuScroller
-
setScrollerFor
Registers a menu to be scrolled, with the specified scrolling interval.- Parameters:
menu- the menuinterval- the scroll interval, in milliseconds- Returns:
- the MenuScroller
- Throws:
IllegalArgumentException- if scrollCount or interval is 0 or negative- Since:
- 7463
-
setScrollerFor
Registers a popup menu to be scrolled, with the specified scrolling interval.- Parameters:
menu- the popup menuinterval- the scroll interval, in milliseconds- Returns:
- the MenuScroller
- Throws:
IllegalArgumentException- if scrollCount or interval is 0 or negative- Since:
- 7463
-
setScrollerFor
Registers a menu to be scrolled, with the specified scrolling interval, and the specified numbers of items fixed at the top of the menu.- Parameters:
menu- the menuinterval- the scroll interval, in millisecondstopFixedCount- the number of items to fix at the top. May be 0.- Returns:
- the MenuScroller
- Throws:
IllegalArgumentException- if scrollCount or interval is 0 or negative or if topFixedCount is negative- Since:
- 7463
-
setScrollerFor
Registers a popup menu to be scrolled, with the specified scrolling interval, and the specified numbers of items fixed at the top of the popup menu.- Parameters:
menu- the popup menuinterval- the scroll interval, in millisecondstopFixedCount- the number of items to fix at the top. May be 0- Returns:
- the MenuScroller
- Throws:
IllegalArgumentException- if scrollCount or interval is 0 or negative or if topFixedCount is negative- Since:
- 7463
-
getTopFixedCount
Returns the number of items fixed at the top of the menu or popup menu.- Returns:
- the number of items
-
setTopFixedCount
Sets the number of items to fix at the top of the menu or popup menu.- Parameters:
topFixedCount- the number of items
-
dispose
Removes this MenuScroller from the associated menu and restores the default behavior of the menu. -
refreshMenu
-