public class JMenuScroller
extends java.lang.Object
Implementation note: The default number of items to display at a time is MenuEntry.DEFAULT_MAX_ROWS, and the default scrolling interval is 125 milliseconds.
Modified from: http://www.camick.com/java/source/MenuScroller.java
Constructor and Description |
---|
JMenuScroller(javax.swing.JMenu menu)
Constructs a
JMenuScroller that scrolls a menu with the
default number of items to display at a time, and default scrolling
interval. |
JMenuScroller(javax.swing.JMenu menu,
int scrollCount)
Constructs a
JMenuScroller that scrolls a menu with the
specified number of items to display at a time, and default scrolling
interval. |
JMenuScroller(javax.swing.JMenu menu,
int scrollCount,
int interval)
Constructs a
JMenuScroller that scrolls a menu with the
specified number of items to display in the scrolling region, and the
specified scrolling interval. |
JMenuScroller(javax.swing.JPopupMenu menu)
Constructs a
JMenuScroller that scrolls a popup menu with the
default number of items to display at a time, and default scrolling
interval. |
JMenuScroller(javax.swing.JPopupMenu menu,
int scrollCount)
Constructs a
JMenuScroller that scrolls a popup menu with the
specified number of items to display at a time, and default scrolling
interval. |
JMenuScroller(javax.swing.JPopupMenu menu,
int scrollCount,
int interval)
Constructs a
JMenuScroller that scrolls a popup menu with the
specified number of items to display in the scrolling region, and the
specified scrolling interval. |
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Removes this JMenuScroller from the associated menu and restores the
default behavior of the menu.
|
void |
finalize()
Ensures that the
dispose method of this JMenuScroller is
called when there are no more refrences to it. |
int |
getInterval()
Returns the scroll interval in milliseconds
|
int |
getscrollCount()
Returns the number of items in the scrolling portion of the menu.
|
void |
keepVisible(int index)
Scrolls the item at the specified index into view each time the menu is
opened.
|
void |
keepVisible(javax.swing.JMenuItem item)
Scrolls the specified item into view each time the menu is opened.
|
void |
setInterval(int interval)
Sets the scroll interval in milliseconds
|
void |
setScrollCount(int scrollCount)
Sets the number of items in the scrolling portion of the menu.
|
static JMenuScroller |
setScrollerFor(javax.swing.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 JMenuScroller |
setScrollerFor(javax.swing.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 JMenuScroller |
setScrollerFor(javax.swing.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 JMenuScroller |
setScrollerFor(javax.swing.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 JMenuScroller |
setScrollerFor(javax.swing.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 JMenuScroller |
setScrollerFor(javax.swing.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.
|
public JMenuScroller(javax.swing.JMenu menu)
JMenuScroller
that scrolls a menu with the
default number of items to display at a time, and default scrolling
interval.menu
- the menupublic JMenuScroller(javax.swing.JPopupMenu menu)
JMenuScroller
that scrolls a popup menu with the
default number of items to display at a time, and default scrolling
interval.menu
- the popup menupublic JMenuScroller(javax.swing.JMenu menu, int scrollCount)
JMenuScroller
that scrolls a menu with the
specified number of items to display at a time, and default scrolling
interval.menu
- the menuscrollCount
- the number of items to display at a timejava.lang.IllegalArgumentException
- if scrollCount is 0 or negativepublic JMenuScroller(javax.swing.JPopupMenu menu, int scrollCount)
JMenuScroller
that scrolls a popup menu with the
specified number of items to display at a time, and default scrolling
interval.menu
- the popup menuscrollCount
- the number of items to display at a timejava.lang.IllegalArgumentException
- if scrollCount is 0 or negativepublic JMenuScroller(javax.swing.JMenu menu, int scrollCount, int interval)
JMenuScroller
that scrolls a menu with the
specified number of items to display in the scrolling region, and the
specified scrolling interval.menu
- the menuscrollCount
- the number of items to display in the scrolling portioninterval
- the scroll interval, in millisecondsjava.lang.IllegalArgumentException
- if scrollCount or interval is 0 or negativepublic JMenuScroller(javax.swing.JPopupMenu menu, int scrollCount, int interval)
JMenuScroller
that scrolls a popup menu with the
specified number of items to display in the scrolling region, and the
specified scrolling interval.menu
- the popup menuscrollCount
- the number of items to display in the scrolling portioninterval
- the scroll interval, in millisecondsjava.lang.IllegalArgumentException
- if scrollCount or interval is 0 or negativepublic static JMenuScroller setScrollerFor(javax.swing.JMenu menu)
menu
- the menupublic static JMenuScroller setScrollerFor(javax.swing.JPopupMenu menu)
menu
- the popup menupublic static JMenuScroller setScrollerFor(javax.swing.JMenu menu, int scrollCount)
menu
- the menuscrollCount
- the number of items to display at a timejava.lang.IllegalArgumentException
- if scrollCount is 0 or negativepublic static JMenuScroller setScrollerFor(javax.swing.JPopupMenu menu, int scrollCount)
menu
- the popup menuscrollCount
- the number of items to display at a timejava.lang.IllegalArgumentException
- if scrollCount is 0 or negativepublic static JMenuScroller setScrollerFor(javax.swing.JMenu menu, int scrollCount, int interval)
menu
- the menuscrollCount
- the number of items to be displayed at a timeinterval
- the scroll interval, in millisecondsjava.lang.IllegalArgumentException
- if scrollCount or interval is 0 or negativepublic static JMenuScroller setScrollerFor(javax.swing.JPopupMenu menu, int scrollCount, int interval)
menu
- the popup menuscrollCount
- the number of items to be displayed at a timeinterval
- the scroll interval, in millisecondsjava.lang.IllegalArgumentException
- if scrollCount or interval is 0 or negativepublic int getInterval()
public void setInterval(int interval)
interval
- the scroll interval in millisecondsjava.lang.IllegalArgumentException
- if interval is 0 or negativepublic int getscrollCount()
public void setScrollCount(int scrollCount)
scrollCount
- the number of items to display at a timejava.lang.IllegalArgumentException
- if scrollCount is 0 or negativepublic void keepVisible(javax.swing.JMenuItem item)
null
to restore the default behavior, which
is to show the menu as it last appeared.item
- the item to keep visiblekeepVisible(int)
public void keepVisible(int index)
-1
to restore the default
behavior, which is to show the menu as it last appeared.index
- the index of the item to keep visiblekeepVisible(javax.swing.JMenuItem)
public void dispose()
public void finalize() throws java.lang.Throwable
dispose
method of this JMenuScroller is
called when there are no more refrences to it.finalize
in class java.lang.Object
java.lang.Throwable
- if an error occurs.dispose()