• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to use JMenuItem as JMenu?

 
martin chile
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I want to place a JMenuItem instead of inside a JMenu directly in the JMenuBar (in a way it works). Is there a solution for this or do I have to place something else into the JMenuBar that can be used as a sort of Button and does not open a Menu. I can not use a JToolBar.
Thanks,
Martin
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking at the (class hierarchy ladder at the top of the discussion section of the) api for the JMenuItem, JMenu and JMenuBar classes you can see that each class inherits from/extends JComponent and that JMenuItem extends AbstractButton. So JMenuItem is a button and it is a JComponent. Looks like you could add the JMenuItem directly to the JMenuBar.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!