• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Scrolling JMenu

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to add a scrollbar to a JMenu for menus with a long list of items?

Thanks.
Jeff Storey
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's an idea:
 
Jeff Storey
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Craig:

I have actually been working on a solution similar to this one, although the problem seems to be when this scrolling menu is used as an item in a popup menu. I have a popup menu with 3 items, one of which is another menu (the scrolling menu), so I should be able to mouse over that and display the scrolling list of items. It works until I want to press the scroll bar. The popup menu thinks that I have clicked on another component and hides itself. Do you see what I'm saying and have any thoughts on how to get around this?

Thanks.
Jeff
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The popup menu thinks that I have clicked on another component and hides itself. Do you see what I'm saying and have any thoughts on how to get around this?
Yes, I ran into the same problem. You may have to write some plaf code to get around this. I'd start with both JMenu and BasicMenuUI and look for the behavior that you want to modify. You can often extend the class and override/modify a few things to get what you want. The behavior seems complex so I would guess that it wouldn't be productive to replicate everything in your custom component. You never know...
 
Jeff Storey
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the meantime, I think I've found a hack to this solution. I use a second popup menu that is not actually an item in the first and just trick the menu to show that second popup menu (a BasicComboPopup) when the mouse is in the appropriate location. Seems to be doing the trick for the most part. I appreciate the help.

Jeff
 
I've got no option but to sell you all for scientific experiments. Or a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic