Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4399488

Bug report on JApplet menu while displayed in another HTML Frame

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3
    • None
    • 1.3.0
    • client-libs

    Description



      Name: yyT116575 Date: 12/19/2000


      C:\>java -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      I have created a Japplet. I am using it in a page with two frames. It's sole
      purpose is to be used as a menu, which includes submenus. The size of the
      applet in the frame is height(100%), and width(20), so that when I click on the
      menu it should come to the lower frame. It comes down to the lower frame and
      it sticks to the screen. Even if you move the window or click in the window,
      the menu remains there. It will disappear only if you click on the applet. This
      is a minor one(But this problem does't exist in AWT). The real problem is as
      below:

      Suppose I click on New in the file menu. Afterwards I click on Open in the
      file menu.Suppose some other item with a submenu is sandwitched in
      between new and Open. After clicking on New and Open, if I bring the
      mouse over to that item, it throws an exception, both for appletviewer and in
      the java console of the Broswer. I am using IE 5 and IE 5.5 browser.
      The exception is:


      Exception occurred during event dispatching:

      java.lang.NullPointerException: null pData
      at sun.awt.windows.WInputMethod.handleNativeIMEEvent(Native Method)
      at sun.awt.windows.WInputMethod.dispatchEvent(WInputMethod.java:275)
      at sun.awt.im.InputContext.dispatchEvent(InputContext.java:202)
      at sun.awt.im.InputMethodContext.dispatchEvent
      (InputMethodContext.java:177)
      at java.awt.Component.dispatchEventImpl(Component.java:2529)
      at java.awt.Container.dispatchEventImpl(Container.java:1213)
      at java.awt.Component.dispatchEvent(Component.java:2499)
      at java.awt.LightweightDispatcher.retargetMouseEvent
      (Container.java:2451)
      at java.awt.LightweightDispatcher.trackMouseEnterExit
      (Container.java:2318)
      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2189)
      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
      at java.awt.Container.dispatchEventImpl(Container.java:1200)
      at java.awt.Window.dispatchEventImpl(Window.java:912)
      at java.awt.Component.dispatchEvent(Component.java:2499)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
      at java.awt.EventDispatchThread.pumpOneEvent
      (EventDispatchThread.java:103)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)”


      After this, I cannot select that item which created this exception.

      The code files included are:

      AppTest.html
      FrameTest.html
      MyApplet.java
      Sample.html

      If you OpenFrameTest.html and use the applet as I said, the exception occurs.
      The codes are attached:


      AppTest.html
      **********************************************
      <HTML>
      <HEAD><TITLE>Applet test page</TITLE></HEAD>
      <BODY>
      <!--"CONVERTED_APPLET"-->
      <!-- CONVERTER VERSION 1.3 -->
      <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
      WIDTH = 400 HEIGHT = 20
      codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">
      <PARAM NAME = CODE VALUE = "MyApplet.class" >

      <PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
      <PARAM NAME="scriptable" VALUE="false">
      <PARAM NAME = font VALUE ="Comic Sans MS">
      <PARAM NAME = fontcolor VALUE ="yellow">
      <PARAM NAME = selfontcolor VALUE ="blue">
      <PARAM NAME = selbackcolor VALUE ="black">
      <PARAM NAME = backcolor VALUE ="red">
      <COMMENT>
      <EMBED type="application/x-java-applet;version=1.3" CODE = "MyApplet.class"
      WIDTH = 400 HEIGHT = 20 font = "Comic Sans MS" fontcolor = "yellow"
      selfontcolor = "blue" selbackcolor = "black" backcolor = "red" scriptable=false
      pluginspage="http://java.sun.com/products/plugin/1.3/plugin-
      install.html"><NOEMBED></COMMENT>

      </NOEMBED></EMBED>
      </OBJECT>

      <!--
      <APPLET CODE = "MyApplet.class" WIDTH = 400 HEIGHT = 20>
      <PARAM NAME = font VALUE ="Comic Sans MS">
      <PARAM NAME = fontcolor VALUE ="yellow">
      <PARAM NAME = selfontcolor VALUE ="blue">
      <PARAM NAME = selbackcolor VALUE ="black">
      <PARAM NAME = backcolor VALUE ="red">
      </APPLET>
      -->
      <!--"END_CONVERTED_APPLET"-->

      </BODY>
      </HTML>

      **********************************************

      FrameTest.html
      **********************************************
      <html>
      <frameset rows="10%,*">
      <frame name="one" src="AppTest.html"/>
      <frame name="two" src="Sample.html"/>
      </frameset>
      </html>
      **********************************************


      MyApplet.java
      **********************************************
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import java.util.*;

      public class MyApplet extends JApplet implements ActionListener{
        public void init(){
          initialize();
          readParameters();
          mBar=new JMenuBar();
          setJMenuBar(mBar);
          mBar.add(makeMenu("File",new Object[]{"New",makeMenu("Exit",new Object[]{makeMenu("Exit&Save",new Object[]
            {"Exit&SaveAll","Exit&SaveCurrent"},this),"ExitNoSave"},this),"Open","Save"},this));
          mBar.add(makeMenu("Edit",new Object[]{"Cut","Copy","Paste"},this));
          mBar.setBackground(backCol);
        }

        // This method adds a menu, with the strings or other objects passed in the
        // Object array and returns a reference to it.
        private JMenu makeMenu(Object parent, Object[] items, Object target){
          JMenu menu=null;
          if(parent instanceof String){
            menu=new JMenu((String)parent);
          }
          else if(parent instanceof JMenu){
            menu=(JMenu)parent;
          }
          else{
            JOptionPane.showMessageDialog(this,"Wrong Menu","Menu Error",JOptionPane.ERROR_MESSAGE);
          }
          for(int i=0;i<items.length;i++){
            if(items[i]==null)
              menu.addSeparator();
            else{
              menu.add(makeMenuItem(items[i],target));
            }
          }
          if(menu!=null){
            menu.setFont(font);
            menu.setBackground(backCol);
            menu.setForeground(fonCol);
          }
          return menu;
        }

        //This method creates a menu Item and adds a listener to it. The reference is returned.
        private JMenuItem makeMenuItem(Object item, Object target){
          JMenuItem mItem=null;
          if(item instanceof String){
            mItem=new JMenuItem((String)item);
          }
          else if(item instanceof JMenuItem){
            mItem=(JMenuItem)item;
          }
          else{
            JOptionPane.showMessageDialog(this,"Wrong MenuItem","Menu Item Error",JOptionPane.ERROR_MESSAGE);
          }
          if(target instanceof ActionListener){
            mItem.addActionListener((ActionListener)target);
          }
          if(mItem!=null){
            mItem.setFont(font);
            mItem.setBackground(backCol);
            mItem.setForeground(fonCol);
          }
          return mItem;
        }

        public void actionPerformed(ActionEvent e){
          String name=e.getActionCommand();
          JOptionPane.showMessageDialog(this,"You clicked "+name,"Info",JOptionPane.INFORMATION_MESSAGE);
        }
        //This method initializes all the Parameter variables
        private void initialize(){
          fonCol=SystemColor.menuText;//new Color(SystemColor.menuText.getRGB());
          selFontCol=SystemColor.textHighlightText ;
          selBackCol=SystemColor.textHighlight;
          backCol=SystemColor.menu;
          font=new Font("SansSerif",Font.BOLD,10);
        }
        private void readParameters(){
          //To retrieve the color parameteres//////////////////////////////////////////
          Color fonColP=getColor(getParameter("fontcolor").trim());
          Color selFontColP=getColor(getParameter("selfontcolor").trim());
          Color selBackColP=getColor(getParameter("selbackcolor").trim());
          Color backColP=getColor(getParameter("backcolor").trim());
          //To retrieve the font parameter////////////////////////////////////////////
          Font tempFont=new Font(getParameter("font").trim(),Font.BOLD,12);
          if(tempFont!=null) font=tempFont;
          if(fonColP!=null) fonCol=fonColP;
          if(selFontColP!=null) selFontCol=selFontColP;
          if(selBackColP!=null) selBackCol=selBackColP;
          if(backColP!=null) backCol=backColP;
          //readMenu();
        }
        private Color getColor(String colorName){
          if(colorName.equals("black")) return Color.black;
          else if(colorName.equals("blue")) return Color.blue;
          else if(colorName.equals("cyan")) return Color.cyan;
          else if(colorName.equals("darkGray")) return Color.darkGray;
          else if(colorName.equals("gray")) return Color.gray;
          else if(colorName.equals("green")) return Color.green;
          else if(colorName.equals("lightGray")) return Color.lightGray;
          else if(colorName.equals("magenta")) return Color.magenta;
          else if(colorName.equals("orange")) return Color.orange;
          else if(colorName.equals("pink")) return Color.pink;
          else if(colorName.equals("red")) return Color.red;
          else if(colorName.equals("white")) return Color.white;
          else if(colorName.equals("yellow")) return Color.yellow;
          else return null;
        }

        private JMenuBar mBar;
        private Font font;
        private Color fonCol;
        private Color selFontCol;
        private Color selForeCol;
        private Color selBackCol;
        private Color foreCol;
        private Color backCol;
      }
      **********************************************

      Sample.html
      **********************************************
      <HTML>
      <HEAD><TITLE>Applet test page</TITLE></HEAD>
      <BODY>
      </BODY>
      </HTML>
      **********************************************
      (Review ID: 114014)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              naoto Naoto Sato
              yyoungsunw Yung-ching Young (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: