Package org.apache.jorphan.gui
Class MenuScroller
java.lang.Object
org.apache.jorphan.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 and/or bottom of
 the menu.
 
Implementation note: The default number of items to display at a time is 15, and the default scrolling interval is 125 milliseconds.
Class is slightly changed as per comments on the webpage
- 
Constructor SummaryConstructorsConstructorDescriptionMenuScroller(JMenu menu) Constructs aMenuScrollerthat scrolls a menu with the default number of items to display at a time, and default scrolling interval.MenuScroller(JMenu menu, int scrollCount) Constructs aMenuScrollerthat scrolls a menu with the specified number of items to display at a time, and default scrolling interval.MenuScroller(JMenu menu, int scrollCount, int interval) Constructs aMenuScrollerthat scrolls a menu with the specified number of items to display at a time, and specified scrolling interval.MenuScroller(JMenu menu, int scrollCount, int interval, int topFixedCount, int bottomFixedCount) Constructs aMenuScrollerthat scrolls a menu with the specified number of items to display in the scrolling region, the specified scrolling interval, and the specified numbers of items fixed at the top and bottom of the menu.MenuScroller(JPopupMenu menu) Constructs aMenuScrollerthat scrolls a popup menu with the default number of items to display at a time, and default scrolling interval.MenuScroller(JPopupMenu menu, int scrollCount) Constructs aMenuScrollerthat scrolls a popup menu with the specified number of items to display at a time, and default scrolling interval.MenuScroller(JPopupMenu menu, int scrollCount, int interval) Constructs aMenuScrollerthat scrolls a popup menu with the specified number of items to display at a time, and specified scrolling interval.MenuScroller(JPopupMenu menu, int scrollCount, int interval, int topFixedCount, int bottomFixedCount) Constructs aMenuScrollerthat scrolls a popup menu with the specified number of items to display in the scrolling region, the specified scrolling interval, and the specified numbers of items fixed at the top and bottom of the popup menu.
- 
Method SummaryModifier and TypeMethodDescriptionvoiddispose()Removes this MenuScroller from the associated menu and restores the default behavior of the menu.intReturns the number of items fixed at the bottom of the menu or popup menu.intReturns the scroll interval in millisecondsintReturns the number of items in the scrolling portion of the menu.intReturns the number of items fixed at the top of the menu or popup menu.voidkeepVisible(int index) Scrolls the item at the specified index into view each time the menu is opened.voidkeepVisible(JMenuItem item) Scrolls the specified item into view each time the menu is opened.voidsetBottomFixedCount(int bottomFixedCount) Sets the number of items to fix at the bottom of the menu or popup menu.voidsetInterval(int interval) Sets the scroll interval in millisecondsvoidsetScrollCount(int scrollCount) Sets the number of items in the scrolling portion of the menu.static MenuScrollersetScrollerFor(JMenu menu) Registers a menu to be scrolled with the default number of items to display at a time and the default scrolling interval.static MenuScrollersetScrollerFor(JMenu menu, int scrollCount) Registers a menu to be scrolled with the default number of items to display at a time and the specified scrolling interval.static MenuScrollersetScrollerFor(JMenu menu, int scrollCount, int interval) Registers a menu to be scrolled, with the specified number of items to display at a time and the specified scrolling interval.static MenuScrollersetScrollerFor(JMenu menu, int scrollCount, int interval, int topFixedCount, int bottomFixedCount) Registers a menu to be scrolled, with the specified number of items to display in the scrolling region, the specified scrolling interval, and the specified numbers of items fixed at the top and bottom of the menu.static MenuScrollersetScrollerFor(JPopupMenu menu) Registers a popup menu to be scrolled with the default number of items to display at a time and the default scrolling interval.static MenuScrollersetScrollerFor(JPopupMenu menu, int scrollCount) Registers a popup menu to be scrolled with the default number of items to display at a time and the specified scrolling interval.static MenuScrollersetScrollerFor(JPopupMenu menu, int scrollCount, int interval) Registers a popup menu to be scrolled, with the specified number of items to display at a time and the specified scrolling interval.static MenuScrollersetScrollerFor(JPopupMenu menu, int scrollCount, int interval, int topFixedCount, int bottomFixedCount) Registers a popup menu to be scrolled, with the specified number of items to display in the scrolling region, the specified scrolling interval, and the specified numbers of items fixed at the top and bottom of the popup menu.voidsetTopFixedCount(int topFixedCount) Sets the number of items to fix at the top of the menu or popup menu.
- 
Constructor Details- 
MenuScrollerConstructs aMenuScrollerthat scrolls a menu with the default number of items to display at a time, and default scrolling interval.- Parameters:
- menu- the menu
 
- 
MenuScrollerConstructs aMenuScrollerthat scrolls a popup menu with the default number of items to display at a time, and default scrolling interval.- Parameters:
- menu- the popup menu
 
- 
MenuScrollerConstructs aMenuScrollerthat scrolls a menu with the specified number of items to display at a time, and default scrolling interval.- Parameters:
- menu- the menu
- scrollCount- the number of items to display at a time
- Throws:
- IllegalArgumentException- if scrollCount is 0 or negative
 
- 
MenuScrollerConstructs aMenuScrollerthat scrolls a popup menu with the specified number of items to display at a time, and default scrolling interval.- Parameters:
- menu- the popup menu
- scrollCount- the number of items to display at a time
- Throws:
- IllegalArgumentException- if scrollCount is 0 or negative
 
- 
MenuScrollerConstructs aMenuScrollerthat scrolls a menu with the specified number of items to display at a time, and specified scrolling interval.- Parameters:
- menu- the menu
- scrollCount- the number of items to display at a time
- interval- the scroll interval, in milliseconds
- Throws:
- IllegalArgumentException- if scrollCount or interval is 0 or negative
 
- 
MenuScrollerConstructs aMenuScrollerthat scrolls a popup menu with the specified number of items to display at a time, and specified scrolling interval.- Parameters:
- menu- the popup menu
- scrollCount- the number of items to display at a time
- interval- the scroll interval, in milliseconds
- Throws:
- IllegalArgumentException- if scrollCount or interval is 0 or negative
 
- 
MenuScrollerpublic MenuScroller(JMenu menu, int scrollCount, int interval, int topFixedCount, int bottomFixedCount) Constructs aMenuScrollerthat scrolls a menu with the specified number of items to display in the scrolling region, the specified scrolling interval, and the specified numbers of items fixed at the top and bottom of the menu.- Parameters:
- menu- the menu
- scrollCount- the number of items to display in the scrolling portion
- interval- the scroll interval, in milliseconds
- topFixedCount- the number of items to fix at the top. May be 0
- bottomFixedCount- the number of items to fix at the bottom. May be 0
- Throws:
- IllegalArgumentException- if scrollCount or interval is 0 or negative or if topFixedCount or bottomFixedCount is negative
 
- 
MenuScrollerpublic MenuScroller(JPopupMenu menu, int scrollCount, int interval, int topFixedCount, int bottomFixedCount) Constructs aMenuScrollerthat scrolls a popup menu with the specified number of items to display in the scrolling region, the specified scrolling interval, and the specified numbers of items fixed at the top and bottom of the popup menu.- Parameters:
- menu- the popup menu
- scrollCount- the number of items to display in the scrolling portion
- interval- the scroll interval, in milliseconds
- topFixedCount- the number of items to fix at the top. May be 0
- bottomFixedCount- the number of items to fix at the bottom. May be 0
- Throws:
- IllegalArgumentException- if scrollCount or interval is 0 or negative or if topFixedCount or bottomFixedCount is negative
 
 
- 
- 
Method Details- 
setScrollerForRegisters a menu to be scrolled with the default number of items to display at a time and the default scrolling interval.- Parameters:
- menu- the menu
- Returns:
- the MenuScroller
 
- 
setScrollerForRegisters a popup menu to be scrolled with the default number of items to display at a time and the default scrolling interval.- Parameters:
- menu- the popup menu
- Returns:
- the MenuScroller
 
- 
setScrollerForRegisters a menu to be scrolled with the default number of items to display at a time and the specified scrolling interval.- Parameters:
- menu- the menu
- scrollCount- the number of items to display at a time
- Returns:
- the MenuScroller
- Throws:
- IllegalArgumentException- if scrollCount is 0 or negative
 
- 
setScrollerForRegisters a popup menu to be scrolled with the default number of items to display at a time and the specified scrolling interval.- Parameters:
- menu- the popup menu
- scrollCount- the number of items to display at a time
- Returns:
- the MenuScroller
- Throws:
- IllegalArgumentException- if scrollCount is 0 or negative
 
- 
setScrollerForRegisters a menu to be scrolled, with the specified number of items to display at a time and the specified scrolling interval.- Parameters:
- menu- the menu
- scrollCount- the number of items to be displayed at a time
- interval- the scroll interval, in milliseconds
- Returns:
- the MenuScroller
- Throws:
- IllegalArgumentException- if scrollCount or interval is 0 or negative
 
- 
setScrollerForRegisters a popup menu to be scrolled, with the specified number of items to display at a time and the specified scrolling interval.- Parameters:
- menu- the popup menu
- scrollCount- the number of items to be displayed at a time
- interval- the scroll interval, in milliseconds
- Returns:
- the MenuScroller
- Throws:
- IllegalArgumentException- if scrollCount or interval is 0 or negative
 
- 
setScrollerForpublic static MenuScroller setScrollerFor(JMenu menu, int scrollCount, int interval, int topFixedCount, int bottomFixedCount) Registers a menu to be scrolled, with the specified number of items to display in the scrolling region, the specified scrolling interval, and the specified numbers of items fixed at the top and bottom of the menu.- Parameters:
- menu- the menu
- scrollCount- the number of items to display in the scrolling portion
- interval- the scroll interval, in milliseconds
- topFixedCount- the number of items to fix at the top. May be 0.
- bottomFixedCount- the number of items to fix at the bottom. May be 0
- Returns:
- the MenuScroller
- Throws:
- IllegalArgumentException- if scrollCount or interval is 0 or negative or if topFixedCount or bottomFixedCount is negative
 
- 
setScrollerForpublic static MenuScroller setScrollerFor(JPopupMenu menu, int scrollCount, int interval, int topFixedCount, int bottomFixedCount) Registers a popup menu to be scrolled, with the specified number of items to display in the scrolling region, the specified scrolling interval, and the specified numbers of items fixed at the top and bottom of the popup menu.- Parameters:
- menu- the popup menu
- scrollCount- the number of items to display in the scrolling portion
- interval- the scroll interval, in milliseconds
- topFixedCount- the number of items to fix at the top. May be 0
- bottomFixedCount- the number of items to fix at the bottom. May be 0
- Returns:
- the MenuScroller
- Throws:
- IllegalArgumentException- if scrollCount or interval is 0 or negative or if topFixedCount or bottomFixedCount is negative
 
- 
getIntervalpublic int getInterval()Returns the scroll interval in milliseconds- Returns:
- the scroll interval in milliseconds
 
- 
setIntervalpublic void setInterval(int interval) Sets the scroll interval in milliseconds- Parameters:
- interval- the scroll interval in milliseconds
- Throws:
- IllegalArgumentException- if interval is 0 or negative
 
- 
getscrollCountpublic int getscrollCount()Returns the number of items in the scrolling portion of the menu.- Returns:
- the number of items to display at a time
 
- 
setScrollCountpublic void setScrollCount(int scrollCount) Sets the number of items in the scrolling portion of the menu.- Parameters:
- scrollCount- the number of items to display at a time
- Throws:
- IllegalArgumentException- if scrollCount is 0 or negative
 
- 
getTopFixedCountpublic int getTopFixedCount()Returns the number of items fixed at the top of the menu or popup menu.- Returns:
- the number of items
 
- 
setTopFixedCountpublic void setTopFixedCount(int topFixedCount) Sets the number of items to fix at the top of the menu or popup menu.- Parameters:
- topFixedCount- the number of items
 
- 
getBottomFixedCountpublic int getBottomFixedCount()Returns the number of items fixed at the bottom of the menu or popup menu.- Returns:
- the number of items
 
- 
setBottomFixedCountpublic void setBottomFixedCount(int bottomFixedCount) Sets the number of items to fix at the bottom of the menu or popup menu.- Parameters:
- bottomFixedCount- the number of items
 
- 
keepVisibleScrolls the specified item into view each time the menu is opened. Call this method withnullto restore the default behavior, which is to show the menu as it last appeared.- Parameters:
- item- the item to keep visible
- See Also:
 
- 
keepVisiblepublic void keepVisible(int index) Scrolls the item at the specified index into view each time the menu is opened. Call this method with-1to restore the default behavior, which is to show the menu as it last appeared.- Parameters:
- index- the index of the item to keep visible
- See Also:
 
- 
disposepublic void dispose()Removes this MenuScroller from the associated menu and restores the default behavior of the menu.
 
-