• Post Reply Bookmark Topic Watch Topic
  • New Topic

attaching drop down menu in JToolbar  RSS feed

 
kit james
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a newbie question here, I would like to know how do we attach a drop down menu to a button in the JToolbar ?

I could not figure out how it works for days thank you

regards
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the most bar a JToolBar is just like a JPanel or any other container. So just add a JComboBox to it. Just like you add JButton's to it.

 
kit james
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ops
mayb I get myself wrong,

wat I mean is like the JButtons in JToolbar

when we click on the button in toolbar something like a dropdown menu will appear

something that we often c in Borland JBuilder and MsWord

For eg: when we click the icon New

there will be another list of drop down menu listed
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, this proves more difficult. Well, kind of. The easiest thing to do is us a JPopupMenu. Take a look at the Menu Tutorial from Sun and halfway down the page they tell you how to create a JPopupMenu. What you will do is create this popup menu when the JButton is clicked and just position the popupmenu right under the JButton.

I'm sure you could go into as much detail as you wanted and create a custom component for this, but I wouldn't want to.
 
kit james
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!