Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9249191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:07:51+00:00 2026-06-18T10:07:51+00:00

I add a menu to a toolbar like this : JMenuBar menu = new

  • 0

I add a menu to a toolbar like this :

    JMenuBar menu = new JMenuBar();
    JMenu actions = new JMenu("Aktionen");
    Icon menuIcon = ImageUtilities.loadImageIcon("pathToIcon", true);
    actions.setIcon(menuIcon);

    // Add
    JMenuItem addItem = new JMenuItem("Add");       
    Icon addIcon = ImageUtilities.loadImageIcon("pathToIcon", true);
    addItem.setIcon(addIcon);
    addItem.setToolTipText("Add new Item");
    addItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            AddItemAction someAction = new AddItemAction();
            someAction.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null) {
                // Foo
            });
        }
    });        

    menu.add(actions);
    actions.add(addItem);
    toolbar.addSeparator();
    toolbar.add(menu);  

Basically, it works fine. But, it never displays the tooltip (“Add new Item”). Any hints ?

EDIT: Just in case someone with the same problem stumbles upon this: it was the L&F, as I should have suspected from the beginning. It has a property for displaying tooltips of JMenuItems ; and it defaults to false.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:07:53+00:00Added an answer on June 18, 2026 at 10:07 am

    The sscce below works correctly. If you still have problems, please edit your question to include an example that exhibits the problem you describe.

    Addendum: I added the menu to a JToolBar, and it still works, either docked or free-floating.

    import java.awt.EventQueue;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JToolBar;
    
    /** @see http://stackoverflow.com/a/14630345/230513 */
    public class Test {
    
        private void display() {
            JFrame f = new JFrame("Test");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JMenuBar menu = new JMenuBar();
            JMenu actions = new JMenu("Aktionen");
            JMenuItem addItem = new JMenuItem("Add");
            addItem.setToolTipText("Add new Item");
            menu.add(actions);
            actions.add(addItem);
            JToolBar toolbar = new JToolBar("Tools");
            toolbar.add(menu);
            f.add(toolbar);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        }
    
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    new Test().display();
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to add button to toolbar or menu item to menu in
SHORT: I would like to add a drop-down menu to the quick access toolbar
I am making excel add-in in which clicking on menu item or toolbar button,
I am trying to add a new menu item to Eclipse's popupmenus. It really
I want to have a toolbar-like menu at the bottom of an activity, and
I would like to add a gap between two buttons on an Eclipse toolbar.
I have an existing toolbar and would like to add tabs to it that
I add toolbar buttons dynamically based on settings file. I would like to assign
I'd like to add a menu system to my simple OpenGL program. I've used
I want to add menu at footer in Drupal. (e.g. contact us | sitemap

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.