Scrolling a JPopupMenu (Scrollable JPopupMenu)

I’ve just come across a need for a JPopupMenu with lots of menu items and found out scrolling support if not built on? Shock! Horror!

After using Google to look for options and finding everything over-engineered or doing some weird things like not supporting the keyboard I decided to create my own.

JScrollPopupMenu extends JPopupMenu but adds:

  • top and bottom scroll buttons
  • support for mouse and keyboard scrolling
  • definable number of items to display before scrolling functionality kicks in
  • controllable scrolling speed

Below is a Java Applet demonstrating JScrollPopupMenu functionality.

The same concept could be used to create multiple scrollable menus where the menu has many submenus with many items.

The source code for JScrollPopupMenu can be found here –

The code has been documented with Javadoc so you can create your own documentation straight from the code.

About Warren Cross

A contract IT professional that has been in the technology industry a number of years at various blue chip companies. During his career he has been a successful application developer, analyst, project manager, IT manager and system administrator, and performed in both global and local roles. For contract opportunities feel free to contact Warren through this site.
This entry was posted in Java, learning by example. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *