Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

How to use JMenuItem as JMenu?

Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
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.
You can thank my dental hygienist for my untimely aliveness. So tiny:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic