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

MouseEvent.this.isPopupTrigger always returns false inside JTree on Linux

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.3.1
    • client-libs



      Name: yyT116575 Date: 03/08/2001


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

      See attached source code.

      On Windows platform, the user can right click on the tree nodes and 1) the node
      that the mouse is over becomes selected, and 2) the popup menu appears.

      On Linix (RedHat 7.x), 1 and 2 above do not occur. The isPopupTrigger returns
      false.

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

      public class JTreePopupMenu extends Object {

        public static void main(final String[] args) {
          final java.util.Hashtable table = new java.util.Hashtable();
          table.put("node 1", new Object[] {"leaf 1", "leaf 2", "leaf 3"});
          table.put("node 2", new Object[] {"leaf 1", "leaf 2", "leaf 3"});
          table.put("node 3", new Object[] {"leaf 1", "leaf 2", "leaf 3"});
          final JTree tree = new JTree(table);
          final JPopupMenu popup = new JPopupMenu();
          final JFrame frame = new JFrame("JTree PopupMenu Test");
          popup.add(new JMenuItem("Item 1"));
          popup.add(new JMenuItem("Item 2"));
          popup.add(new JMenuItem("Item 3"));
          tree.addMouseListener(new MouseAdapter() {
            public void mouseReleased(MouseEvent event) {
              int x = event.getX();
              int y = event.getY();
              tree.setSelectionPath(tree.getClosestPathForLocation(x, y));
              if (event.isPopupTrigger()) {
                popup.show(tree, x, y);
              }
            }
          });
          frame.getContentPane().add(new JScrollPane(tree));
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.pack();
          frame.show();
        }
      }
      (Review ID: 118240)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: