public class MenuScroller
extends java.lang.Object
Implementation note: The default number of items to display at a time is 15, and the default scrolling interval is 125 milliseconds.
Constructor and Description |
---|
MenuScroller(javax.swing.JMenu menu)
Constructs a
MenuScroller that scrolls a menu with the default number of items to display at a time,
and default scrolling interval. |
MenuScroller(javax.swing.JMenu menu,
int scrollCount)
Constructs a
MenuScroller that scrolls a menu with the specified number of items to display at a
time, and default scrolling interval. |
MenuScroller(javax.swing.JMenu menu,
int scrollCount,
int interval)
Constructs a
MenuScroller that scrolls a menu with the specified number of items to display at a
time, and specified scrolling interval. |
MenuScroller(javax.swing.JMenu menu,
int scrollCount,
int interval,
int topFixedCount,
int bottomFixedCount)
Constructs a
MenuScroller that 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(javax.swing.JPopupMenu menu)
Constructs a
MenuScroller that scrolls a popup menu with the default number of items to display at a
time, and default scrolling interval. |
MenuScroller(javax.swing.JPopupMenu menu,
int scrollCount)
Constructs a
MenuScroller that scrolls a popup menu with the specified number of items to display at
a time, and default scrolling interval. |
MenuScroller(javax.swing.JPopupMenu menu,
int scrollCount,
int interval)
Constructs a
MenuScroller that scrolls a popup menu with the specified number of items to display at
a time, and specified scrolling interval. |
MenuScroller(javax.swing.JPopupMenu menu,
int scrollCount,
int interval,
int topFixedCount,
int bottomFixedCount)
Constructs a
MenuScroller that 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. |
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Removes this MenuScroller from the associated menu and restores the default behavior of the menu.
|
void |
finalize()
Ensures that the
dispose method of this MenuScroller is called when there are no more references to
it. |
int |
getBottomFixedCount()
Returns the number of items fixed at the bottom of the menu or popup menu.
|
int |
getInterval()
Returns the scroll interval in milliseconds
|
int |
getscrollCount()
Returns the number of items in the scrolling portion of the menu.
|
int |
getTopFixedCount()
Returns the number of items fixed at the top of the menu or popup 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.
|
static void |
main(java.lang.String[] args) |
void |
setBottomFixedCount(int bottomFixedCount)
Sets the number of items to fix at the bottom of the menu or popup menu.
|
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 MenuScroller |
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 MenuScroller |
setScrollerFor(javax.swing.JMenu menu,
java.awt.Component comp,
int interval,
int topFixedCount,
int bottomFixedCount) |
static MenuScroller |
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 MenuScroller |
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 MenuScroller |
setScrollerFor(javax.swing.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 MenuScroller |
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 MenuScroller |
setScrollerFor(javax.swing.JPopupMenu menu,
java.awt.Component comp,
int interval,
int topFixedCount,
int bottomFixedCount) |
static MenuScroller |
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 MenuScroller |
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.
|
static MenuScroller |
setScrollerFor(javax.swing.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.
|
void |
setTopFixedCount(int topFixedCount)
Sets the number of items to fix at the top of the menu or popup menu.
|
public MenuScroller(javax.swing.JMenu menu)
MenuScroller
that scrolls a menu with the default number of items to display at a time,
and default scrolling interval.menu
- the menupublic MenuScroller(javax.swing.JPopupMenu menu)
MenuScroller
that scrolls a popup menu with the default number of items to display at a
time, and default scrolling interval.menu
- the popup menupublic MenuScroller(javax.swing.JMenu menu, int scrollCount)
MenuScroller
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 MenuScroller(javax.swing.JPopupMenu menu, int scrollCount)
MenuScroller
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 MenuScroller(javax.swing.JMenu menu, int scrollCount, int interval)
MenuScroller
that scrolls a menu with the specified number of items to display at a
time, and specified scrolling interval.menu
- the menuscrollCount
- the number of items to display at a timeinterval
- the scroll interval, in millisecondsjava.lang.IllegalArgumentException
- if scrollCount or interval is 0 or negativepublic MenuScroller(javax.swing.JPopupMenu menu, int scrollCount, int interval)
MenuScroller
that scrolls a popup menu with the specified number of items to display at
a time, and specified scrolling interval.menu
- the popup menuscrollCount
- the number of items to display at a timeinterval
- the scroll interval, in millisecondsjava.lang.IllegalArgumentException
- if scrollCount or interval is 0 or negativepublic MenuScroller(javax.swing.JMenu menu, int scrollCount, int interval, int topFixedCount, int bottomFixedCount)
MenuScroller
that 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.menu
- the menuscrollCount
- the number of items to display in the scrolling portioninterval
- the scroll interval, in millisecondstopFixedCount
- the number of items to fix at the top. May be 0bottomFixedCount
- the number of items to fix at the bottom. May be 0java.lang.IllegalArgumentException
- if scrollCount or interval is 0 or negative or if topFixedCount or
bottomFixedCount is negativepublic MenuScroller(javax.swing.JPopupMenu menu, int scrollCount, int interval, int topFixedCount, int bottomFixedCount)
MenuScroller
that 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.menu
- the popup menuscrollCount
- the number of items to display in the scrolling portioninterval
- the scroll interval, in millisecondstopFixedCount
- the number of items to fix at the top. May be 0bottomFixedCount
- the number of items to fix at the bottom. May be 0java.lang.IllegalArgumentException
- if scrollCount or interval is 0 or negative or if topFixedCount or
bottomFixedCount is negativepublic static MenuScroller setScrollerFor(javax.swing.JMenu menu)
menu
- the menupublic static MenuScroller setScrollerFor(javax.swing.JPopupMenu menu)
menu
- the popup menupublic static MenuScroller 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 MenuScroller 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 MenuScroller 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 MenuScroller 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 static MenuScroller setScrollerFor(javax.swing.JMenu menu, int scrollCount, int interval, int topFixedCount, int bottomFixedCount)
menu
- the menuscrollCount
- the number of items to display in the scrolling portioninterval
- the scroll interval, in millisecondstopFixedCount
- the number of items to fix at the top. May be 0.bottomFixedCount
- the number of items to fix at the bottom. May be 0java.lang.IllegalArgumentException
- if scrollCount or interval is 0 or negative or if topFixedCount or
bottomFixedCount is negativepublic static MenuScroller setScrollerFor(javax.swing.JMenu menu, java.awt.Component comp, int interval, int topFixedCount, int bottomFixedCount)
public static MenuScroller setScrollerFor(javax.swing.JPopupMenu menu, int scrollCount, int interval, int topFixedCount, int bottomFixedCount)
menu
- the popup menuscrollCount
- the number of items to display in the scrolling portioninterval
- the scroll interval, in millisecondstopFixedCount
- the number of items to fix at the top. May be 0bottomFixedCount
- the number of items to fix at the bottom. May be 0java.lang.IllegalArgumentException
- if scrollCount or interval is 0 or negative or if topFixedCount or
bottomFixedCount is negativepublic static MenuScroller setScrollerFor(javax.swing.JPopupMenu menu, java.awt.Component comp, int interval, int topFixedCount, int bottomFixedCount)
public 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 int getTopFixedCount()
public void setTopFixedCount(int topFixedCount)
topFixedCount
- the number of itemspublic int getBottomFixedCount()
public void setBottomFixedCount(int bottomFixedCount)
bottomFixedCount
- the number of itemspublic 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 MenuScroller is called when there are no more references to
it.finalize
in class java.lang.Object
java.lang.Throwable
- if an error occurs.dispose()
public static void main(java.lang.String[] args)
Copyright © 2004-2014 FEUP-LSTS and Neptus developers. All Rights Reserved.