Results 1 to 5 of 5
- 12-14-2011, 05:24 AM #1
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
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
- 12-14-2011, 05:29 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
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.
- 12-14-2011, 05:49 AM #3
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.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 12-14-2011, 05:53 AM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
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.
- 12-19-2011, 02:17 AM #5
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
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
-
I am getting a cannot find symbol error on this code from Oracle Java tutorial site
By bigsonny in forum New To JavaReplies: 8Last Post: 06-15-2011, 05:26 AM -
JMenuBar error
By Tastosis in forum New To JavaReplies: 6Last Post: 03-02-2011, 11:55 AM -
Mutliple JMenuBar
By chyrl in forum AWT / SwingReplies: 10Last Post: 11-04-2010, 05:43 AM -
Changing position of JMenuBar
By LianaN in forum New To JavaReplies: 8Last Post: 09-17-2010, 12:41 PM -
JMenubar option
By navishkumarb in forum New To JavaReplies: 3Last Post: 05-24-2010, 02:03 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks