Results 1 to 5 of 5
  1. #1
    KeyLay is offline Member
    Join Date
    Nov 2011
    Posts
    11
    Rep Power
    0

    Default Find a tutorial on changing the JMenuBar

    I have made a GUI and the JMenubar and that works great. I am looking for a tutorial to teach me how to cancel out something. The simplest example I can think of if you go to edit and paste is grayed out. But you cut something and it works great. That is want to learn.

    I have tried creating two bars, and just simply calling frame.setJMenuBar(bar1 or bar 2). However, the second bar is always blank.

    If someone has a good resource let me know. Google didn't help me on this one.

    Thank you,

    Kyle

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default Re: Find a tutorial on changing the JMenuBar

    Cancel out sense, you are talking about undo-redo functionality? I am not clear with what you are saying.

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

    Default Re: Find a tutorial on changing the JMenuBar

    Seems you're looking for setEnabled(true/false). If that's not it, you may find what you want here: How to Use Menus (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

    And since this is a Swing topic, I'm moving the thread to the appropriate forum.

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

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,574
    Rep Power
    12

    Default Re: Find a tutorial on changing the JMenuBar

    How to Use Menus and How to Use Actions in Oracle's Tutorial are worth reading.

    The basic idea is that you create a menu item based on an instance of Action. These action instances can be disabled (they have a method for that) and when they are disabled the corresponding menu item is greyed out. In the example you mention you might check the contents of the clipboard every time you change it with a "cut" and update the paste action (enable/disable) based on whether the clipboard has some content.

  5. #5
    KeyLay is offline Member
    Join Date
    Nov 2011
    Posts
    11
    Rep Power
    0

    Default Re: Find a tutorial on changing the JMenuBar

    Thank you. The reading helped.

    For those people that are trying to do the same thing, I clicked on a series of links that I found myself here: Enabling And Disabling A MenuItem - Java | Dream.In.Code

Similar Threads

  1. Replies: 8
    Last Post: 06-15-2011, 06:26 AM
  2. JMenuBar error
    By Tastosis in forum New To Java
    Replies: 6
    Last Post: 03-02-2011, 12:55 PM
  3. Mutliple JMenuBar
    By chyrl in forum AWT / Swing
    Replies: 10
    Last Post: 11-04-2010, 06:43 AM
  4. Changing position of JMenuBar
    By LianaN in forum New To Java
    Replies: 8
    Last Post: 09-17-2010, 01:41 PM
  5. JMenubar option
    By navishkumarb in forum New To Java
    Replies: 3
    Last Post: 05-24-2010, 03:03 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
  •