Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Swing / AWT / SWT and the fly likes Pulldown Button Menu in JToolBar? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Pulldown Button Menu in JToolBar?" Watch "Pulldown Button Menu in JToolBar?" New topic

Pulldown Button Menu in JToolBar?

Winston Rast

Joined: Jul 03, 2001
Posts: 1
I want to create a menu in a JToolBar just like IE's Back/Forward buttons on its toolbar. I have looked everywhere to try and find some code that might enlighten me on how to do this. Does anyone out there have suggestions on how to proceed?
Vinod Venugopal
Ranch Hand

Joined: Dec 06, 2000
Posts: 148
U can do this on the toolbar button, but this button will be a custom button which opens a popupmenu when the button is clicked. Then u can add whatever u want in the popumenu & act accordingly.
Sample code:
class PopButton extends JButton

//when button is selected or clicked in listener

//the method which pops a popupmenu
PopupMenu pop = new PopupMenu();
pop.add(xyz);//add whatever u want;
This should work.

- Vinod<br />-------<br />SCJP2
I agree. Here's the link:
subject: Pulldown Button Menu in JToolBar?
It's not a secret anymore!