This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
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/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Pulldown Button Menu in JToolBar?" Watch "Pulldown Button Menu in JToolBar?" New topic
Author

Pulldown Button Menu in JToolBar?

Winston Rast
Greenhorn

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?
Thanks.
-wr
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
showPopup();

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


- Vinod<br />-------<br />SCJP2
 
Don't get me started about those stupid light bulbs.
 
subject: Pulldown Button Menu in JToolBar?