Results 1 to 14 of 14
  1. #1
    pseeburger is offline Member
    Join Date
    Jan 2012
    Posts
    14
    Rep Power
    0

    Default Java Applet trouble with Menus in Firefox on Mac

    I have spent a number of years developing applets to help students visualize calculus concepts.

    My most extensive applet is called CalcPlot3D: CalcPlot3D

    See also Exploring Multivariable Calculus.

    It has worked great on Firefox, Safari, and IE on both Macs and Windows, but recently (after Firefox 4.0, and persisting through Firefox 8 and 9), I have had some issues come up in Firefox on the Mac that have been difficult to remedy.

    The one that I have not been able to address to my satisfaction is that the JMenuBar in the applet does not function properly in Firefox on the Mac. If I click on the menubar, it activates the correct JMenu item, but then it will not highlight the menu options as my mouse runs over the options, although until recently it still let me select options using the mouse, at least at first. Most recently it has started jumping to the File menu (the first JMenu in the upper left) and opening that menu instead whenever I try to use the mouse to select an option on another main menu. I can still navigate the menu choices using the keyboard once the menu has been activated by the mouse, but this is really not acceptable.

    I notice that the same issue plagues drop-down menus as well both in my applet and in others I have found on the web. See my drop-down (Choice) menu that appears just above the 2D graph in the lower left corner of the applet.

    The menu system does seem to work fine on any external JDialogs or JFrames I create. This has led me to create an optional link to my applet that opens the applet in a separate JFrame, but although this has been a fun new option, I would really love to have the regular applet in the browser function normally as well.

    Has anyone else encountered this menu problem in Java applets in Firefox on the Mac?

    Does anyone have any suggestions for fixing this behavior (other than doing what I have done)?

    Thanks so much!

    Paul

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,247
    Rep Power
    19

    Default Re: Java Applet trouble with Menus in Firefox on Mac

    Applet or JApplet?

    Do you have a mix of AWT and Swing components?

    db
    Last edited by DarrylBurke; 01-20-2012 at 07:00 AM.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    kbalaji is offline Member
    Join Date
    Dec 2011
    Posts
    1
    Rep Power
    0

    Default Re: Java Applet trouble with Menus in Firefox on Mac

    ru using only mac os or windows too?

    japplet have some setting for mac os

  4. #4
    pseeburger is offline Member
    Join Date
    Jan 2012
    Posts
    14
    Rep Power
    0

    Default Re: Java Applet trouble with Menus in Firefox on Mac

    It is a JApplet. I am developing for use on both Windows and Mac.

    I use mostly Swing components, but there are some AWT components still used in the applet, though none on the JMenuBar.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,247
    Rep Power
    19

    Default Re: Java Applet trouble with Menus in Firefox on Mac

    Quote Originally Posted by kbalaji View Post
    ru using only mac os or windows too?

    japplet have some setting for mac os
    Please go through this web page.

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

  6. #6
    pseeburger is offline Member
    Join Date
    Jan 2012
    Posts
    14
    Rep Power
    0

    Default Re: Java Applet trouble with Menus in Firefox on Mac

    Ok, I have some new information. I have a custom combobox that I created using AWT components and these work fine in Firefox on the Mac. The JComboBox I had used on the JApplet was having the issue (described above) of not highlighting the menu options as the mouse moves down the list, and currently no longer even allowing the items to be selected using the mouse, but flashing up to the first JMenu on the JMenuBar (my File menu). Note that in my first post, I mistakenly indicated that the drop-down menu was a Choice component. It was really a JComboBox component.

    I have observed this same issue in Firefox 8-9 on the Mac with the JComboBox component (and JMenus) on other applets on the web as well.

    Switching the JComboBox back to an AWT Choice component does the trick to address this issue with the JComboBox, but I don't believe there is an option to use AWT for my menus in the JApplet.

    Thanks for any insight anyone may have to address this issue.

    Paul

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,247
    Rep Power
    19

    Default Re: Java Applet trouble with Menus in Firefox on Mac

    Does your code respect Swing's single threaded rule? Have you ensured that all Swing components are constructed and their methods called only on the EDT?

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

  8. #8
    pseeburger is offline Member
    Join Date
    Jan 2012
    Posts
    14
    Rep Power
    0

    Default Re: Java Applet trouble with Menus in Firefox on Mac

    Quote Originally Posted by DarrylBurke View Post
    Does your code respect Swing's single threaded rule? Have you ensured that all Swing components are constructed and their methods called only on the EDT?

    db
    I believe so. I use SwingUtilities.invokeAndWait in my init() method of the JApplet to call another method to create the GUI including the JMenuBar and other GUI elements.

    Here is a JApplet example that shows what I do to create my GUI and that exhibits both of these buggy behaviors in FireFox 9 on a Mac.

    Here is a direct link to a working version on my website: Example Menu Applet

    Here is its code:

    Java Code:
    import javax.swing.*;
    
    public class MenuApplet extends JApplet {
    
      public void init() {
          try {
                javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        createGUI();
                    }
                });
            } catch (Exception e) {
                System.err.println("createGUI didn't successfully complete");
                e.printStackTrace();
            }
      }
        
      public void createGUI() {
        JMenuBar menubar = new JMenuBar();
    
        JMenu menuFile = new JMenu("File");
    
        menuFile.add(new JMenuItem("Open"));
        menuFile.add(new JMenuItem("Save"));
    
        menubar.add(menuFile);
    
        JMenu otherMenu = new JMenu("Other");
        otherMenu.add(new JMenuItem("Option 1"));
        otherMenu.add(new JMenuItem("Option 2"));
        otherMenu.add(new JMenuItem("Option 3"));
        otherMenu.add(new JMenuItem("Option 4"));
        menubar.add(otherMenu);
    
    
        JMenu menuHelp = new JMenu("Help");
        menuHelp.add(new JMenuItem("About"));
        menubar.add(menuHelp);
    
        setJMenuBar(menubar);
    
    
        JComboBox cTrace = new JComboBox();
        cTrace.addItem("Show a trace point on the surface");
        cTrace.addItem("Show the tangent plane at point");
        cTrace.addItem("Show a fx tangent line at point");
        cTrace.addItem("Show a fy tangent line at point");
        cTrace.addItem("Show directional deriv tan line at pt");
        cTrace.addItem("Show the gradient vector at point");
        cTrace.addItem("Show graphs only");
    
        getContentPane().add(cTrace);
      }
    }
    If you have a Mac with Firefox 8 or 9, you can compile it, open it with an HTML page that references it and I expect you will see the same behavior when you attempt to move down any main menu or to select an option in the JComboBox. The focus flashes back to the File menu and accomplishes nothing.

    Paul
    Last edited by pseeburger; 01-21-2012 at 09:49 PM.

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,247
    Rep Power
    19

    Default Re: Java Applet trouble with Menus in Firefox on Mac

    The code looks good, except that I would test if init(0 is already running on the EDT. Pseudocode:
    Java Code:
    IF SwingUtilities.isEventDispatchThread()
        invokeLater(...)
    ELSE
        try/catch invokeAndWait(...)
    But of course, that has nothing to do with your reported problem.

    Sorry, I don't have a mac to see the problem for myself, but I don't think seeing it would help to towards a possible solution. just another random thought: is your OS and Java updated to the latest?

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

  10. #10
    pseeburger is offline Member
    Join Date
    Jan 2012
    Posts
    14
    Rep Power
    0

    Default Re: Java Applet trouble with Menus in Firefox on Mac

    Well, my Java Plugin is the latest version, but I am still using the latest update to Snow Leopard (and not Lion). But then I do want my applet to work on both Snow Leopard AND Lion correctly, so it becomes difficult to check every option myself. Does anyone with Lion see this odd behavior in my example applet above? Others with Snow Leopard?

    Thanks for your ideas, Darryl!

    I am surprised this issue is not mentioned very clearly on the web yet. Either it is somewhat localized (and there is an easy fix for it), or people are just not using Java applets that have menus and JComboBoxes in them as much these days.

    Is anyone else seeing what I am seeing?

    Paul

  11. #11
    shagstrom is offline Member
    Join Date
    Jun 2012
    Posts
    2
    Rep Power
    0

    Default Re: Java Applet trouble with Menus in Firefox on Mac

    Yes, I'm having the same issue.

    I'm using this code:

    Java Code:
    import javax.swing.*;
    
    public class AppletWithMenuBar extends JApplet {
    	
    	public void init() {
    
    		JMenuBar menuBar = new JMenuBar();
    
    		JMenu fileMenu = menuBar.add(new JMenu("File"));
    		fileMenu.add(new JMenuItem("New"));
    		fileMenu.add(new JMenuItem("Open"));
    		fileMenu.add(new JMenuItem("Save"));
    
    		JMenu editMenu = menuBar.add(new JMenu("Edit"));
    		editMenu.add(new JMenuItem("Cut"));
    		editMenu.add(new JMenuItem("Copy"));
    		editMenu.add(new JMenuItem("Paste"));
    		
    		setJMenuBar(menuBar);
    
    	}
    
    }
    XML Code:
    <!DOCTYPE html>
    <html>
    <head>
    	<title></title>
    </head>
    <body>
    	<applet code="AppletWithMenuBar.class" width="400" height="300"></applet>
    </body>
    </html>
    Whenever I try to get to an item in the Edit JMenu, the File JMenu gets highlighted.
    Last edited by shagstrom; 06-01-2012 at 04:41 PM.

  12. #12
    pseeburger is offline Member
    Join Date
    Jan 2012
    Posts
    14
    Rep Power
    0

    Default Re: Java Applet trouble with Menus in Firefox on Mac

    Hi, shagstrom!

    It is nice to know someone else is interested in finding a solution to this issue. I assume this is occuring for you on Firefox on the Mac, am I right?

    Unfortunately, I have not yet found a solution to this behavior that really deals with the issue.

    The one solution I have found is to run the applet in a separate window. See my post at the end of this thread to see how I did that: opening applet in seperate window vs in the page.

    Please let me know if you find anything that helps address this menu issue.

    Paul

  13. #13
    shagstrom is offline Member
    Join Date
    Jun 2012
    Posts
    2
    Rep Power
    0

    Default Re: Java Applet trouble with Menus in Firefox on Mac

    Yes, Firefox on Mac. I have created this post to describe the issue better.

    I have also submitted a bug at Mozilla.

    Quote Originally Posted by pseeburger View Post

    It is nice to know someone else is interested in finding a solution to this issue. I assume this is occuring for you on Firefox on the Mac, am I right?
    Last edited by shagstrom; 06-04-2012 at 10:35 AM.

  14. #14
    lisapoole74 is offline Member
    Join Date
    Apr 2014
    Posts
    1
    Rep Power
    0

    Default Re: Java Applet trouble with Menus in Firefox on Mac

    Thanks for your idea
    Last edited by lisapoole74; 04-28-2014 at 01:06 PM.

Similar Threads

  1. Applet Trouble
    By Cosmos in forum New To Java
    Replies: 1
    Last Post: 09-20-2011, 06:14 AM
  2. Java applet won't display in firefox
    By silverglade in forum Java Applets
    Replies: 6
    Last Post: 05-13-2011, 04:40 AM
  3. Signed Applet crashing FireFox in Ubuntu
    By saurabhbatra in forum Java Applets
    Replies: 1
    Last Post: 06-07-2010, 01:53 AM
  4. How to force Firefox to reload applet
    By JordashTalon in forum Java Applets
    Replies: 3
    Last Post: 02-20-2009, 11:19 AM
  5. applet linking menus
    By lordbob75 in forum Java Applets
    Replies: 0
    Last Post: 01-27-2009, 10:49 PM

Tags for this Thread

Posting Permissions

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