/** * Registers a menu to be scrolled with the default number of items to * display at a time and the default scrolling interval. * * @param menu * the menu * @return the MenuScroller */ public static MenuScroller setScrollerFor(JMenu menu) { return new MenuScroller(menu); }
setScrollCount(scrollCount); setInterval(interval); setTopFixedCount(topFixedCount); setBottomFixedCount(bottomFixedCount);
/** * Ensures that the <code>dispose</code> method of this MenuScroller is * called when there are no more references to it. * * @see MenuScroller#dispose() */ @Override public void finalize() throws Throwable { dispose(); super.finalize(); }
/** * Make menu scrollable * @param menu {@link JMenu} */ public static void makeScrollableMenu(JMenu menu) { if (menu.getItemCount() > 0 && !GraphicsEnvironment.isHeadless()) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // We use 80% of height int maxItems = (int)Math.round( screenSize.getHeight()*0.8/menu.getMenuComponent(0).getPreferredSize().getHeight()); MenuScroller.setScrollerFor(menu, maxItems, 200); } }
/** * Registers a popup menu to be scrolled with the default number of items to * display at a time and the default scrolling interval. * * @param menu * the popup menu * @return the MenuScroller */ public static MenuScroller setScrollerFor(JPopupMenu menu) { return new MenuScroller(menu); }
/** * Registers a menu to be scrolled with the default number of items to * display at a time and the specified scrolling interval. * * @param menu * the menu * @param scrollCount * the number of items to display at a time * @return the MenuScroller * @throws IllegalArgumentException * if scrollCount is 0 or negative */ public static MenuScroller setScrollerFor(JMenu menu, int scrollCount) { return new MenuScroller(menu, scrollCount); }
/** * Registers a popup menu to be scrolled with the default number of items to * display at a time and the specified scrolling interval. * * @param menu * the popup menu * @param scrollCount * the number of items to display at a time * @return the MenuScroller * @throws IllegalArgumentException * if scrollCount is 0 or negative */ public static MenuScroller setScrollerFor(JPopupMenu menu, int scrollCount) { return new MenuScroller(menu, scrollCount); }
/** * Registers a popup menu to be scrolled, with the specified number of items * to display at a time and the specified scrolling interval. * * @param menu * the popup menu * @param scrollCount * the number of items to be displayed at a time * @param interval * the scroll interval, in milliseconds * @return the MenuScroller * @throws IllegalArgumentException * if scrollCount or interval is 0 or negative */ public static MenuScroller setScrollerFor(JPopupMenu menu, int scrollCount, int interval) { return new MenuScroller(menu, scrollCount, interval); }
/** * Registers a menu to be scrolled, with the specified number of items to * display at a time and the specified scrolling interval. * * @param menu * the menu * @param scrollCount * the number of items to be displayed at a time * @param interval * the scroll interval, in milliseconds * @return the MenuScroller * @throws IllegalArgumentException * if scrollCount or interval is 0 or negative */ public static MenuScroller setScrollerFor(JMenu menu, int scrollCount, int interval) { return new MenuScroller(menu, scrollCount, interval); }
/** * 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. * * @param menu * the menu * @param scrollCount * the number of items to display in the scrolling portion * @param interval * the scroll interval, in milliseconds * @param topFixedCount * the number of items to fix at the top. May be 0. * @param 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 * @return the MenuScroller */ public static MenuScroller setScrollerFor(JMenu menu, int scrollCount, int interval, int topFixedCount, int bottomFixedCount) { return new MenuScroller(menu, scrollCount, interval, topFixedCount, 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. * * @param menu * the popup menu * @param scrollCount * the number of items to display in the scrolling portion * @param interval * the scroll interval, in milliseconds * @param topFixedCount * the number of items to fix at the top. May be 0 * @param 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 * @return the MenuScroller */ public static MenuScroller setScrollerFor(JPopupMenu menu, int scrollCount, int interval, int topFixedCount, int bottomFixedCount) { return new MenuScroller(menu, scrollCount, interval, topFixedCount, bottomFixedCount); }