"Slow menus" - what's the problem?

Hi Swing people,
Here is my first experiment with menus. For some reason they seem "slow" compared to menus in other apps. Is this because of me (and my bad programming) or is Java menus just "slow"?
Also, I'm running OS X and would like my menus to be in the menu bar at the top of my screen as "real" OS X apps. How do I do that?
Thanks.
Stefan
- a newbie
Here is my code:
import javax.swing.*;
import java.awt.*;
class MoreSwing
    void swingMe()
        JFrame frame = new JFrame("Should this parameter be an action?");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = frame.getContentPane();
        JMenuBar menuBar = new JMenuBar();
        content.add(menuBar, BorderLayout.PAGE_START);
        JMenu menu;
        JMenuItem item;
        menu = new JMenu("File");
        menuBar.add(menu);
        menu.add(new JMenuItem("New Browser"));
        menu.add(new JMenuItem("New Tab"));
        menu.add(new JMenuItem("New Source Document"));
        menu.add(new JSeparator());
        menu.add(new JMenuItem("Open Location"));
        menu.add(new JMenuItem("Open File"));
        menu.add(new JSeparator());
        menu.add(new JMenuItem("Save"));
        menu = new JMenu("Edit");
        menuBar.add(menu);
        menu.add(new JMenuItem("Undo"));
        menu.add(new JMenuItem("Redo"));
        menu.add(new JSeparator());
        menu.add(new JMenuItem("Cut"));
        menu.add(new JMenuItem("Copy"));
        menu.add(new JMenuItem("Paste"));
        menu.add(new JMenuItem("Paste From File..."));
        menu.add(new JSeparator());       
        menu.add(new JMenuItem("Delete"));
        menu.add(new JMenuItem("Select All"));
        menu = new JMenu("View");
        menuBar.add(menu);
        menu.add(new JMenuItem("Go To Location"));
        menu.add(new JSeparator());       
        menu.add(new JMenuItem("Stop Load"));
        menu.add(new JMenuItem("Reload"));
        menu.add(new JSeparator());       
        menu.add(new JMenuItem("Load All Images"));
        menu.add(new JSeparator());       
        menu.add(new JMenuItem("View In Source Editor"));
        menu = new JMenu("History");
        menuBar.add(menu);
        menu.add(new JMenuItem("Go Back"));
        menu.add(new JMenuItem("Go Forward"));
        menu.add(new JMenuItem("Go To Start Page"));
        menu = new JMenu("Bookmarks");
        menuBar.add(menu);
        menu.add(new JMenuItem("Show Bookmarks Page"));
        menu.add(new JMenuItem("Add To Bookmarks..."));
        menu.add(new JSeparator());       
        menu.add(new JMenuItem("Open Next"));
        menu = new JMenu("Workspace");
        menuBar.add(menu);
        menu.add(new JMenuItem("Show Workspaces"));
        menu.add(new JMenuItem("New Workspace"));
        menu.add(new JMenuItem("Delete Workspace"));
        menu.add(new JSeparator());       
        menu.add(new JMenuItem("Next Workspace"));
        menu.add(new JMenuItem("Previous Workspace"));
        menu.add(new JSeparator());       
        menu.add(new JMenuItem("Take Snapshot"));
        menu.add(new JMenuItem("Restore Snapshot"));
        menu = new JMenu("Window");
        menuBar.add(menu);
        menu.add(new JMenuItem("Close Window"));
        menu.add(new JMenuItem("Minimize Window"));
        menu.add(new JMenuItem("Zoom Window"));
        menu.add(new JSeparator());       
        menu.add(new JMenuItem("Next Tab"));
        menu.add(new JMenuItem("Previous Tab"));
        menu.add(new JMenuItem("Close Tab"));
        menu = new JMenu("Help");
        menuBar.add(menu);
        menu.add(new JMenuItem("Swing Help"));
        menu.add(new JMenuItem("Keyboard Shortcuts"));
        menu.add(new JSeparator());       
        menu.add(new JMenuItem("Acknowledgments"));
        menu.add(new JMenuItem("Swing Product Page"));
        menu.add(new JMenuItem("Send Feedback..."));
        JTextArea text = new JTextArea();
        text.setPreferredSize(new Dimension(700,700));
        content.add(text, BorderLayout.CENTER);
        JTextField field = new JTextField();
        content.add(field, BorderLayout.PAGE_END);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    public static void main(String[] args)
        MoreSwing swingMe = new MoreSwing();
        swingMe.swingMe();
}

You should set the JMenuBar to the JFrame by using frame.setJMenuBar(menuBar);
Read the tutorial:
http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html
Read the "Moving the menu bar" section here:
http://java.sun.com/developer/technicalArticles/JavaLP/JavaToMac/

Similar Messages

  • My macbook pro won't start up at all, it shows a grey screen, before this it was extremely slow. What is the problem?

    My Mac won't start up at all now, it happened again 3 weeks ago and I reinstalled OS and lost everything on my computer
    Now it happened again after it was extremely slow.. what is the problem?

    and how can I fix it without losing everything again?

  • My Macbook Pro purchased Dec 2011 has suddenly become very slow after not using for 2 weeks (close to frozen). What is the problem and how to solve it?

    My Macbook Pro purchased Dec 2011 has suddenly become very slow after not using for 2 weeks (close to frozen). What is the problem and how to solve it?

    Need Help Ye,
    boot your MacBook Pro into Recovery mode by holding down a Command key and the R key as it starts up. Once the Mac OS X Utilities menu appears, select Disk Utility. On the left-hand side of the Disk Utility window, select your internal disk’s boot partition (typically called “Macintosh HD”). On the right-hand side, press the Verify Disk button if it’s not greyed out; if it is greyed out, or if it reports that errors were found, press the Repair Disk button. Once the verification/repair is completed, exit Disk Utility and select Restart from the Apple menu to restart in normal mode. Is it still very slow?

  • Saving after editing in elements 8 - this is painfully slow, including waiting through the "not responding" message, though after quick editing in organiser saving is very quick - what is the problem?

    saving after editing in elements 8 - this is painfully slow, including waiting through the "not responding" message, though after quick editing in organiser saving is very quick - what is the problem?

    None of my pictures that I uploaded into iPhoto are in my Finder under Pictures.  Should I copy and paste my folders from iPhoto into here, in case something happens to my iPhoto program (in addition to backing them up onto an external hard drive like I already do)?
    No, that's just wasting space.  A back up needs to be on a different disk.
    Your photos are within the iPhoto Library.

  • After encoding to apple proress 422 FCPX is working so slow. FCP7 Runs with no issues. What is the problem?

    It took all night to encode my video files into proress 422 using compressor.
    I used compressor because FCPX would not even run or simply crash. Im using an Intel Mac 3.06 GHz Core 2 Duo 4 GB 1067 MHz DDR3 OSX 10.6.8
    After the encode I'm able to work on FCPX but it's running like a snail, the video and audio will not play smooth and the windows or event library will not update after clicking the next folder. And if I use an effect or transition FCPX will crash.
    Now if I use FCP7 everything runs so smooth and it runs light years over FCPX
    WHAT IS THE PROBLEM?   I'm trying my best to like FCPX and really work on this project but I have lost two days of work, just by watching this application run so slow.

    your in the wrong discussion, go here:
    https://discussions.apple.com/community/professional_applications/final_cut_pro_ x?view=discussions

  • I have a mac 15" non retina and i didn't upgrade it to mavericks .. when i run photoshop my pc becomes very slow and i don't know why!! the performance on photoshop is up to 70% so i think is good .. what is the problem?

    i have a mac 15" non retina and i didn't upgrade it to mavericks .. when i run photoshop my pc becomes very slow and i don't know why!! the performance on photoshop is up to 70% so i think is good .. what is the problem?

    All I can suggest is that you open that file on the MBA and save it as a new file, then see if you can open the new one on the iMac.

  • LR 5 is very slow to give me a visual so I can properly select them for import. What's the problem?

    LR 5 is very very very slow in giving me a visual of my images so I can properly select them for import. What's the problem? I'm very disappointed with this glitch! Please Adobe fix it quickly! Has anyone else come across this problem? Any solutions? thanks

    trygzuz wrote:
    LR 5 is very very very slow in giving me a visual of my images so I can properly select them for import. What's the problem? I'm very disappointed with this glitch! Please Adobe fix it quickly! Has anyone else come across this problem? Any solutions? thanks
    Is "very very very slow" 30 seconds or 30 minutes or 30 hours or 30 years?
    It is possible that you have a hardware problem which is causing the slow operation (in my case, it was a bad card reader, but it could also be a bad USB port or USB cable or bad camera card). In fact, in my opinion, these issues are 99.9% of the time hardware issues.

  • When I start mozilla firefox web browser, sometimes I see a message saying that "a Mozilla Firefox is already running, please close it or restart your program", while I don't have one running at that time. What is the problem?

    When I start mozilla firefox web browser, sometimes I see a message saying that "a Mozilla Firefox is already running, please close it or restart your system". As a matter of fact, there is no firefox browser running at that time. Since I cannot do anything about it, I have to restart my computer before I can use the web browser, which bothers me dearly. What is the problem?

    Plug-in and tasks started by Firefox may continue after attempting to close Firefox. The "X" in the upper right-hand corner closes the Window (same as Ctrl+Shift+W) but even if it is the last Firefox window, it does not necessarily close Firefox .
    '''The only proper way to exit Firefox is to use Exit through the File menu''', not the "X" in the upper right corner of last Firefox window.
    ''Menus hidden: then use Alt+F then X.''
    '''Firefox hangs''' | Troubleshooting | Firefox Support ''(some extensions cause a problem)''
    * http://support.mozilla.com/kb/Firefox%20hangs#w_hang-at-exit
    Use the '''Windows Task Manger''' to remove all running firefox.exe in the "Processes"
    tab of the Windows Task Manager, then restart Firefox.
    "'''Restartless Restart'''" extension for Firefox 4.0 only (2 KB download )
    * https://addons.mozilla.org/firefox/addon/249342/
    use to close and restart Firefox after enabling or disabling an extension, switching
    to a new theme, or modifying configuration files, then you don't have to worry
    about delay or have to look in the Task Manager to see if Firefox is closed yet.
    Uses keyboard shortcut "'''Ctrl+Alt+R'''" or a file menu option.
    '''Windows 7''' users can use '''Ctrl+Shift+Esc''' to get to the Windows Task Manager quicker than starting with Ctrl+Alt+Del.

  • My macbook pro keeps rebooting. What is the problem?

    Hi,
         I have a macbook pro that I bought in August 2010.  Performance has been awesome until this past month when I noticed it getting slower.  This past weekend for the first time ever it would freeze and reboot itself.  I took the action to clean up large files, unloaded some apps, etc. all things they say to speed up your mac in the youtube vids.  Cleared up alot of space and it was moving faster for a day.  Then this afternoon it froze again and rebooted, but never successfully rebooted and now is just rebooting constantly.  I cannot even get to the log in screen anymore or turn it off completely....I am going to wait for the battery to die out, but what is the problem?  What can I do to solve this? I downloaded the newest IOS X update this past saturday, thats when I think the rebooting started, but the computer was getting noticeably slower before that.
    Thanks for the help, really dont know what I am doing here

    Time to see about the PRAM battery.
    By the way iOS and OS X are different systems.
    iOS is the operating system for iPads, iPhones, and iPod touch.
    Mac OS X is the operating system for Mac labelled computers.

  • Permissions differ on "Library/Internet Plug-Ins/JavaAppletPlugin.plugin"; should be... WHAT IS THE PROBLEM?

    Permissions differ on “Library/Internet Plug-Ins/JavaAppletPlugin.plugin”; should be... WHAT IS THE PROBLEM?

    My imac OSX 10.8.2 IS awfully slow for opening the different applications, internet etc. I am running the CP monitor and everything seems fine. My speedtest is over 20MB
    The hard disk is not even half full.
    I have ran a utility check and I receive the same message as zolala. I  am trying to repair as I am writing this post and it goes on and on. Not sure it will finish...

  • When I click on 2014 month view in calendar iPhone 5 s stucks, lagging. What is the problem I don't know????

    When I click on 2014 month view in calendar iPhone 5 s stucks, lagging. What is the problem I don't know????

    Should read 'When I '''clicked''' on your update this a.m......

  • TS2446 i have a problem in my account every time i want to install application from app Store on my iphone a message shows that my Apple ID has been disabled, what is the problem? what can i do ?

    i have a problem in my account every time i want to install application from app Store on my iphone a message shows that my Apple ID has been disabled, i creat a new password and still that message shoes ,what is the problem ?can you help me please???!!!!

    If your account is disabled then you might be able to re-enable it via this page : http://appleid.apple.com, then 'reset your password'
    You might then need to log out of your account on your phone by tapping on your id in Settings > iTunes & App Store and then log back in so as to 'refresh' the account on it
    If that doesn't fix it then you might need to contact iTunes Support : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page

  • I have installed Itunes 10.5 on my PC and I have turned photostream on on my Ipad2 and Iphone.  The photos sync fine but they are not showing up on my PC.   What's the problem?

    I have installed Itunes 10.5 on my PC and I have turned photostream on on my Ipad2 and Iphone.  The photos sync fine but they are not showing up on my PC.   What's the problem?  I can see my photos on my ipad and Iphone.   I want to be able to see them on my PC when I take pictures from my Iphone and Ipad.  How do I see Photostream on my PC?

    You have to install the iCloud control panel for windows, then sign in with you apple ID, and check what you want to sync.
    link: http://support.apple.com/kb/DL1455

  • HT1657 When I try to rent a movie from iTunes on my Apple TV it says the purchase could not be completed. My password is correct as well as my location and other information. What is the problem?

    When I try to rent a movie on my Apple TV it states that the purchase could not be completed. My password is correct and location, user id, and other settings are correct. What is the problem?

    If you are also getting a message to contact iTunes Support then you can do so via this link and ask them why the message is appearing (we are fellow users here on these user-to-user forums, we won't know why) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • I have a mid 2011 macbook air and a new Apple TV but I can't mirror. What's the problem? I have checked display settings and I don't have the "allow mirroring" option there.

    What is the problem?

    About AirPlay and Airplay Mirroring
    AirPlay Mirroring requires a second-generation Apple TV or later, and is supported on the following Mac models: iMac (Mid 2011 or newer), Mac mini (Mid 2011 or newer), MacBook Air (Mid 2011 or newer), and MacBook Pro (Early 2011 or newer). For non-qualifying Macs you can try using Air Parrot.
    Several Apple Articles Regarding AirPlay
    Apple TV (2nd and 3rd gen)- How to use AirPlay Mirroring
    How to set up and configure AirPort Express for AirPlay and iTunes
    iTunes- Troubleshooting AirPlay and AirPlay Mirroring
    iTunes- Using AirPlay
    Apple TV (2nd and 3rd gen)- Understanding AirPlay settings
    About AirPlay Mirroring in OS X Mountain Lion
    iTunes 10- About playing music with AirPlay
    Troubleshooting AirPlay and AirPlay Mirroring
    Using AirPlay
    Thanks to the $15 Beamer, AirPlay streaming is still possible on Macs  that do not support Airplay and mirroring.
    Other solutions are the Air Parrot, StreamToMe, and AirServer.

Maybe you are looking for