Results 1 to 6 of 6
  1. #1
    atrodeyo is offline Member
    Join Date
    Apr 2012
    Posts
    41
    Rep Power
    0

    Default Menu Issue Help Please

    Lets say I have File, Edit Menu on the Menu bar. and under File I have 'Enable Edit' and 'Disable Edit' menuItems. By Clicking on 'Enabling Edit' will Enable the Edit Menu and let the user will see all the menuItems under edit and clicking on the 'Disable Edit' will disable or gray out the Edit Menu.

    This is what I did which did not work. It always showed me grayed out even when I clicked on 'Enable Edit'.


    .... for the File menu part I have...
    myItem.addActionListenter ( new ActionListener () {
    public void actionPerformed (ActionEvent e) {
    displayMenu = true;
    JMenuBar myMenuBar = new JMenuBar ();
    JMenu myMenu = editMenu (displayMenu);
    myMenuBar.add(myMenu);
    }
    }
    );
    .......for the edit part I have.......

    private JMenu editMenu (boolean b) {
    JMenu myMenu = new JMenu ("Edit");
    myMenu.setEnabled (b);
    JMenuItem myItem = new JMenuItem ("first Item");
    myMenu.add(myItem);
    }

  2. #2
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    301
    Rep Power
    4

    Default Re: Menu Issue Help Please

    Your actionPerformed should work with already existing menu items and not always create new ones as it is now the case.

  3. #3
    atrodeyo is offline Member
    Join Date
    Apr 2012
    Posts
    41
    Rep Power
    0

    Default Re: Menu Issue Help Please

    Quote Originally Posted by milovan View Post
    Your actionPerformed should work with already existing menu items and not always create new ones as it is now the case.
    I debugged through it and yes actionPerformed does work and it does go to editMenu but still the editMenu does not get enabled when I click on 'Enable Edit' Menu Item. Its always greyout.

  4. #4
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    301
    Rep Power
    4

    Default Re: Menu Issue Help Please

    Ok, can you post your edited code... And use CODE tags

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,305
    Rep Power
    20

    Default Re: Menu Issue Help Please

    To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem. Not uncompilable snippets, and not anything unrelated to the problem for which you seek help.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,305
    Rep Power
    20

    Default Re: Menu Issue Help Please

    Moved from New to Java

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. dropdown menu getting overlapped issue
    By jeev81 in forum Advanced Java
    Replies: 0
    Last Post: 02-02-2011, 12:03 PM
  2. Fill a menu dynamically when menu is shown
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-07-2008, 04:47 PM
  3. How to use SWT menu and menu event
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-07-2008, 04:46 PM
  4. React to menu action and checkbox menu
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-27-2008, 07:50 PM
  5. Replies: 7
    Last Post: 05-09-2008, 07:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •