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

  • Home
  • SEARCH
  • 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 3808274
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:07:21+00:00 2026-05-19T15:07:21+00:00

I constructed a JMenu and would now like to add menu items. So what

  • 0

I constructed a JMenu and would now like to add menu items. So what I have is:

  • JMenu jm
  • Action act

Now, for adding a menu item triggering action act: Does it make a difference if I use

jm.add(act);

or

jm.add(new JMenuItem(act));

?

  • 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-05-19T15:07:22+00:00Added an answer on May 19, 2026 at 3:07 pm

    According to the documentation for JMenu.add(Action), it will create a new menu item for you, so they are essentially the same. So it’s ultimately a convenience method.

    However, it also states:

    As of 1.3, this is no longer the
    preferred method for adding Actions to
    a container. Instead it is recommended
    to configure a control with an action
    using setAction, and then add that
    control directly to the Container.

    And if we look at the source code for JMenu (retrieved from Google Code Search), this is what the add(Action) method looks like:

    public JMenuItem add(Action a) {
        JMenuItem mi = createActionComponent(a);
        mi.setAction(a);
        add(mi);
        return mi;
    }
    

    So no, there isn’t a big difference. But I’d still follow the documentation’s recommendation by manually making a control anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Python Decimal doesn't support being constructed from float; it expects that you have to
Greetings, I have a particular object which can be constructed from a file, as
I am currently building a Neural Network library. I have constructed it as an
I have a constructor like as follows: public Agent(){ this.name = John; this.id =
I constructed an XmlDocument and now I want to convert it to an array.
I have constructed a frameset which is meant to center a webpage in the
I have a inefficiently constructed form that is obviously sending one type of data
I've got some ListView . Each list element is constructed using layout looking like
I want to send an array constructed in javascript with the selected values of
How can I construct my ajaxSend call, this seems like the place to put

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.