MenuListener and menus

Hi everybody,
I know I've asked a lot of questions today, but I've been working on this at least 6 hours and I'm stumped. This is the last one today, I promise. :)
I have a MenuBar with multiple menus, and some of the menus don't have any items in them; they can just be selected or deselected. When those "empty" menus are selected, a dialog window is supposed to pop up and the menu is supposed to be deselected once the dialog pops up.
In my SSCCE, this functionality works fine, the first time. If you click on the "empty" menu, the dialog box pops up and the menu is deselected. If you click on the "empty" menu again, though, the "empty" menu is highlighted, and the box doesn't come up. You have to click on the menu again to un-highlight it. And finally, if you click a third time, the menu does what it's supposed to do again. So, basically, every other time you click on the "empty" menu, the menu does something wrong.
My SSCCE is:
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
public class MenuSelectionTest implements MenuListener {
     public static void main(String args[]) {new MenuSelectionTest();}
     public MenuSelectionTest() {
          try {
               JFrame frame = new JFrame();
               frame.setSize( 200, 200 );
               frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
               JMenuBar bar = new JMenuBar();
               JMenu one = new JMenu( "one" );
               one.add( new JMenuItem( "blah" ) );
               JMenu two = new JMenu( "two" );
               two.addMenuListener( this );
               bar.add( one );
               bar.add( two );
               frame.add( bar, BorderLayout.NORTH );
               frame.setVisible( true );
          } catch( Exception e ) {
               e.printStackTrace();
               System.exit( -1 );
     public void menuCanceled(MenuEvent e) {
          // TODO Auto-generated method stub
     public void menuDeselected(MenuEvent e) {
          // TODO Auto-generated method stub
     public void menuSelected(MenuEvent e) {
          JOptionPane.showMessageDialog( null, "Test" );
          ((JMenu)e.getSource()).setSelected( false );
}Can anyone give me pointers on how to fix this, please?
Thanks,
Jezzica85

Thanks again Darryl,
Actually, I probably should have been a little more clear in my last answer. My SSCCE now works, but it's a test program. The raw text of my real program is:
     final JMenu source = (JMenu)e.getSource();
     SwingUtilities.invokeLater( new Runnable() {
         public void run() {
          source.setSelected( false );
          actionPerformed( null );          
      });Could it have something to do with the fact that I'm calling actionPerformed, do you think?
EDIT: And oops, I almost forgot -- Linux Fedora 7, JDK 6u10.
Thanks,
Jezzica85
Edited by: jezzica85 on Oct 28, 2008 2:12 PM

Similar Messages

  • How do I disable/remove the toolbar and menus in Acrobat 9.x?

    The toolbar and menus are making the files crash in Solaris 11 when magnification is used or a menu item is selected.

    I have published my .cptx files to .pdf then the customer opens them with Adobe Reader. I'm hoping I can remove Reader's toolbar and menus from view when Adobe Reader is opened. People keep trying to use the Reader tools to zoom in and out of the training file, which forces the Reader to close.
    Silly customers.

  • Disable/Remove tool bar and menus?

    Can I disable or remove the toolbar and menus from Reader? If one of my customers opens a file then uses a toolbar or menu item, Reader crashes. Customer is using Solaris 11. This was not broken when using Solaris 10. Using v9.x.

    You can disable toolbar & menu items using JavaScript.

  • Operating system Mac OS 10.6.8. Recently upgraded to CS6 Encore. There are no buttons and menus in Library at bottom right of screen, so cannot put a button on the menu in Flowchart

    How can I get buttons and menus in Library in the Encore 6 screen? There are none showing in my just upgraded Encore 6, when they were there in Encore CS5.

    Richard, the link you provided is correct, but it involves a two step process that first gives only a few templates, then requires another download that gives all the library.
    I think most users who ask the question just want the second step, which is all that is presented here:
    Encore Help | Download full library content/functional content
    When I first started recommended that option, I expected users to ask for the "other" templates, but in Encore, that includes "styles" (that do not appear to be used much) and flash export templates (that are also not used much). So I go straight for the full library that I know the users wants.
    The other oddity is for a user upgrading from CS5.5 (EN 5.1), and keeping 5.1 installed, the installer (your link) involves the bizarre step of DELETING the 5.1 library.
    For Premiere CC users looking to get PR templates/styles, they must use your link.

  • Is it possible to make the pasteboard and menus not so dark?

    We just upgraded to the new CC version of Indesign. Is it possible to make the paste board and menus/palletes white, or at least not so dark? It is very difficult to see darker colors in the color palette. The high contrast between the dark pasteboard and the white page gives me a splitting headache.

    apologies for the double post. I was not sure how this worked, and did not think it went through the first time. Can you diresct me to where that answer is? We did not see a reply regarding that.
    Thank you for your reply.

  • IE 8 Size of Windows, Boxes and Menus

    Satellite A665-S6086, Win 7 Home Prem 64, IE 8.
    1. I want every window to open full-size, not reduced size, without double-clicking the window title, clicking the maximize icon or dragging the window borders after opening.  What settings should I change to do this?
    2. I recently compared information on two sites by dragging the entire window of one site half-way down the screen, i.e., I was looking at the top half of both sites simultaneously.  I dragged the window back up before I closed it.  Now, after the first one during a browsing session, subsequent windows open half-size with the bottom located half way up the screen.  How can I get all windows to open full size?
    3. Even when windows are full size, whether in IE or not, dialog boxes and menu selections often run off the bottom of the screen when using the laptop display or an external monitor.  It is much worse when I use my 32-inch HDTV.  All display, monitor and TV setting are either selected automatically by Windows or set at the optimum recommended settings.  I tried adjusting the TV aspect ratio to maximize the view of dialog boxes and menus, then returned the settings to view content. To get around these problems I go to Control Panel, Display, and set the magnification lower when working with the offending menus and boxes, then return to my preferred settings, but shouldn't they fit (or be able to be scrolled) at 125% or 150%?  Monitor connected by VGA, HDTV by HDMI.
    Can the answers to any of these questions be found in any online documentation from MS or Toshiba?  Any help would be appreciated.

    I can provide a partial answer to my questions.
    1 and 2, regarding the size of windows: To get all windows to open full size, open a window and, if it is not full size already, use the pointer to drag the borders to the size you want for all subsequent windows.  DO NOT USE THE MAXIMIZE ICON (the square near the upper right-hand corner).  Right-click a link on the page and select Open in a New Window, and again drag the borders of this new window to the size you want.  When you have opened two windows that you resized, go back to the first one and close it by pressing the CTRL key then clicking the Close icon (the X in the upper right-hand corner).  Repeat this for the subsequent windows in order.  Now all windows should open to the size you want.  This is the procedure as described in the Microsoft Answers web site.

  • Whenever I play youtube videos on my apple tv the youtube logo and menus are superimposed on the image.  Any suggestions how to see just the video?

    I am unable to figure out how to view a youtube video without the youtube logo and the menus superimposed over the image.  Any suggestions?

    Found the answer on my own; restart apple TV and menus no longer appear over videos and while playing music.  However, viewing streaming video on airplay is not ideal.  Sometimes the image freezes on the TV while it continues on my macbook.  Also, sometimes the sound comes from the tv speakers; other times it comes only from the computer.  Never know what will happen when I watch a streaming video. 

  • Header Logo and Menus strange movement when browser minimized

    When my demo site is minimized http://fingerprint02.businesscatalyst.com/ the logo and menus seem to be off sync and not minimizing gracefully. I have read about 100% widths and tried to put a rectangle around, I have tried this and moved rectangle to the back but it doesnt seem to work.
    Any help would be great, thanks

    Try removing the pinning applied to the logo and menu bar. Your logo is pinned to top center and your menu is pinned to top right of the browser, causing those effects.
    Cheers,
    Vikas

  • Difference between HRMS and SHRMS in taskflow and menus

    Dear friends,
    what is the differents between HRMS version with SHRMS.
    GLOBAL SHRMS POSITION TASKFLOW
    GLOBAL HRMS POSITION TASKFLOW
    GLOBAL HRMS PERSON TASKFLOW
    GLOBAL SHRMS PERSON TASKFLOW
    also in Menu
    GLB SHRMS Navigator
    GLB HRMS Navigator
    Is this 'S' for Super or Self Service version.
    what is the impact or any additional features?
    appreciate your help
    thanks
    zamora

    Duplicate post
    difference between HRMS and SHRMS in taskflow and menus
    Srini

  • Missing Text and Menus in iTunes

    Few weeks ago I noticed that there was missing key text and menus from my iTunes. At current it is mostly a inconvenience but there maybe a day soon that I might want to use these menus and functionality. I think this first started month or so ago after a windows update, but I am not certain. Currently iTunes is the only application that has the symtoms. I have tried resetting my fonts to default changing themes with no luck....
    See picture below for example:

    The support document for future reference:
    TS4338: iTunes for Windows: Troubleshooting missing menus and text in iTunes
    tt2

  • Internationalise iviews and menus

    Translation worklist coordinator:
    hi all,
    i want to translate my iview names and menus to German.i did one sample eg. with one iview. proceeded in the following way:
    1.Create a Worklist Translation
    A2.dd content to translation worklist
    3.Generate Translation data
    Worklist Translation:
    1.Translate worklist
    2.Save and mark worklist as “translated”
    Translation worklist coordinator:
    1.Load Worklist into the Portal
    But even after the last step my iview is displayed in english itslf in portal.have given this iview to a user also. do i have to do anyother step for internationalise my things?
    thnks and regards
    kukku

    hi Jane,
    thanks a lot!!! it worked for me. i selected the language for user as german and it worked!!!.have contributed points to u..
    thanks a lot...
    regards
      kukku

  • I can't load correctly buttons and menus in my wordpress admin page

    I can't load correctly buttons and menus in my wordpress admin page.
    For example, the buttons about upload images, videos and music are too close together and they don't work.
    In the right and left menues icons appear partially and out of place, sometimes one over the other.
    It works in IE.

    Stan -
    Thanks again for the simple but valuable tip.
    I'm just going to repeat the relevant sections from my previous post with the screenshots this time:
    Below you'll see a snip of how my current folder structure appears. It's identical to yours, except there are no button files in the General Folder. Since you were kind enough to include a file name, I did a search on that specific one and it's nowhere to be found on my hard drive. Hmmm....
    I've seen others remark on how... "challenging".... Adobe's instructions can be sometime. I'll admit to having the same feeling when I was trying to download and install all the content files and the 7-zip stuff. Is the answer somehow that I screwed up that?  Note the 7-zip folder right above the Adobe folder. Here's a screen shot of that expanded folder contents:
    Does that look like you think it should? Have I not installed or extracted something correctly?
    Finally, the only other thing I can think of to give you as much info as you might need is to include a screenshot of where the "Functional Content" stuff got saved. Adobe's instructions about this (if I recall correctly) were that it did NOT have to be installed anywhere specific, but you then had to go into Encore (& Premiere) and through preferences point to this stuff, which I believe I did. But I don't see any button type files in these anyway.
    Other thoughts or advice?
    Thanks!

  • Logos and Menus on all pages

    I wish to stop using frames. How can I manage logos and menus
    from a central point?

    Server-side includes.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "kwame_za" <[email protected]> wrote in
    message
    news:g9h07t$gig$[email protected]..
    >I wish to stop using frames. How can I manage logos and
    menus from a
    >central point?

  • Problem with firefox and menus

    I have an intermittent problem in Firefox with menus.  I click on a menu or a drop down button and, as soon as I move my mouse over the menu, it disappears.  The only way to select something on the menu is to leave my mouse where it is and use the arrow keys and enter to select an item.
    Not sure if it's relevant, but I'm using fluxbox as my window manager.

    There has been a bugreport about this, I can't find it right now, but this seems to be a bigger issue. I had this behavior with i3. The behavior was a bit different than you described, but it also affected the menus, so it's related. And yes, this made me very angry as well

  • ICal dead. Interface and menus permanently frozen.

    Hey,
    My iCal has remained inaccessible for the past few days. At launch, the interface is visible, but I doesn't do anything. When I select a menu item such as Preferences, nothing happens. If I select 'Back up iCal', a requester pops down for a moment then just as quickly disappears. I can't change From Day/Week/Month view on the interface, but can temporality from the menus. If another window obscures the App, that portion will lose its border shading.
    iCal's basically completely useless. A real drag since I rely on iCal for so much of my business (I'm a film director) and I'm kinda screwed right now. Any help would be greatly appreciated, including recommendations for switching to a different and more stable calendar app.
    Some specs:
    Running iCal on both by Intel MacBook and Dual PowerPC G5 tower. Using latest version of Leopard.
    Thanks in advance,
    meni

    tblum,
    Quit iCal, and try removing the com.apple.iCal.plist file from your Macintosh HD/Users/yourusername/Library/Preferences Folder.
    Use Finder>Go>Depress the "Option" key>Library>Preferences. Drag the .plist file to your desktop, log out/in or restart and check iCal for functionality.

Maybe you are looking for

  • Limitation of BitmapData loaded into memory through Loader.load()

    I am creating a photo gallery using Loader.load() to load pictures into Flash Player 9. I plan to make them preloaded in advance so when the users turn the page they can see the pic on the new page right away without waiting. So the pics are loaded o

  • RSS Feed of Survey results doesn't show all responses

    Hope someone can help here. I have setup 5 surveys in sharepoint and want to export and analyse the data. I'm aware of the issue which means that because I've used rating scales, when I export to excel the questions output but the responses do not so

  • ISE, Active directory and OUs

    Hello Everyone I have an ISE with an AD integration, i am trying to limit the access to the wireless users, i only added one OU "wireless users", but all the users can access to the wireless network, i just want to allow the access to the users in th

  • Trouble scanning into Photoshop Elements 11 from Canoscan 8800F

    Each time I scan several photos into Photoshop Elements 11 a few of the photos go to my selected file and one or more say they were not imported because they already exist in the APPData/Local/Temp/PSAlbumImport file.  I then have to try to figure ou

  • HT3952 Mail Merge - Pages 5?

    Hello all, Maybe I'm just not seeing the right function, but I can't find mail merge anywhere. I have about 50 envelopes that I send out nearly every holiday, and with this latest update of Pages mail merge seems to have dissapeared. I'm not really s