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

JMenuItem does not highlight when mouse moves over it

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 1.3.0
    • client-libs



      Name: sl110371 Date: 07/06/2000


      java version "1.3.0beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0beta-b07)
      Java HotSpot(TM) Client VM (build 1.3.0beta-b04, mixed mode)

      Please see the source code and description below:



      // Imports
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;



      /**
       * Synopsis:
       * When a menu is opened and the mouse is moved over the items on the menu,
       * they do not highlight under JDK 1.3 beta for Linux. But it works fine
       * with JDK 1.3 for Windows.
       *
       * Here is what java -version prints in the Linux version:
       * java version "1.3.0beta"
       * Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0beta-b07)
       * Java HotSpot(TM) Client VM (build 1.3.0beta-b04, mixed mode)
       *
       * Here is what java -version prints in the Windows 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)
       *
       * Description:
       * Start the programm under JDK 1.3 for Windows and open the menu from the
       * menubar. Move the mouse (without pressing any buttons) over the menu and
       * notice how each menu item automatically highlights when the mouse moves
       * over it.
       * Now do the same thing under JDK 1.3 for Linux. The menu item do not
       * highlight here. The actions that are associated with the menu items are
       * triggered correctly, but the highlighting does not occur until an item is
       * clicked.
       *
       * @author Ralph Kar (###@###.###)
       */
      public class TestApp extends JFrame
      {
          /**
           * Default constructor.
           */
          public TestApp() {
              super("TestApp");

              this.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent ev) {
                      System.exit(0);
                  }
              });

              JMenuBar menuBar = new JMenuBar();

              JMenu menu = new JMenu("Menu 1");

              JMenuItem item1 = new JMenuItem("Item 1");
              item1.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent ev) {
                      System.out.println("Item 1 has been clicked.");
                  }
              });

              JMenuItem item2 = new JMenuItem("Item 2");
              item2.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent ev) {
                      System.out.println("Item 2 has been clicked.");
                  }
              });

              JMenuItem item3 = new JMenuItem("Item 3");
              item3.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent ev) {
                      System.out.println("Item 3 has been clicked.");
                  }
              });

              menu.add(item1);
              menu.add(item2);
              menu.add(item3);

              menuBar.add(menu);

              this.setJMenuBar(menuBar);

              this.setSize(300, 200);
              this.setVisible(true);
          }


          /**
           * Application startup method.
           */
          public static void main(String[] args) {
              new TestApp();
          }
      }
      (Review ID: 106907)
      ======================================================================

            apikalev Andrey Pikalev
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: