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 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

I have constructed a map in the java script like this now i wanna
I have constructed a collection of data series items. Each data series has multiple
I have constructed menu.XML & successfully formatted it with menu.XSL. It works as intended
I have an image on a web page constructed like so: <img src=data:image/png;base64;.... />
I have a RouteLink constructed like so <p class=articleLink> @MvcHelper.Html.RouteLink(article.Title, Article_Route, new RouteValueDictionary() {
The queryset I've constructed is incorrectly leaving out some items. I have three models
I have menu bar constructed from li and a inside. In css I'm trying
I have constructed a query and I'm wondering if it would work on any
I have constructed a class to mimic a C# struct: public class Favourite {
I have constructed an XML tree structure of an XML file. I am able

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.