GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes How add JLabels as headers for JPopupMenu's menuitem sections? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How add JLabels as headers for JPopupMenu Watch "How add JLabels as headers for JPopupMenu New topic
Author

How add JLabels as headers for JPopupMenu's menuitem sections?

Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
I know that menuitems in a JPopupmenu can be separated by addSeparator(), but I also want to be able to set headers/titles for those sections. So you'd get something like:

FILE OPTIONS
- Open File
- Delete File

PROPERTY OPTIONS
- Rename
- View Properties

Is there a way to do this?
Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
Is this possible? Or do I have to extend JPopupMenu
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I don't know of anyway of going that without rolling your own, other than possibly adding a JMenuItem that doesn't have an action attached to it.


GenRocket - Experts at Building Test Data
Tim LeMaster
Ranch Hand

Joined: Aug 31, 2006
Posts: 226
You mean like this?

 
GeeCON Prague 2014
 
subject: How add JLabels as headers for JPopupMenu's menuitem sections?