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

Erroneous mouseClicked events

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.3
    • client-libs
    • None
    • x86
    • windows_95



      Name: joT67522 Date: 08/20/97


      This code displays a window of icons and text labels.
      The idea is that the user clicks a label and then the
      code takes appropriate action (I've not provided complete
      code as it should be possible to substitute out the
      missing bits).

      To reproduce:

      Display the frame - click and drag the window by
      using the titlebar and then move the mouse directly
      over one of the text labels. The result will be a
      rogue mouseClicked event.

      NOTE: The code currently contains a workaround (see
      clickedMouse).

      I suspect this is related to a previous bug -4039858

      /**
      GUI representation of a palette object.
      */
      public class PaletteGui extends Frame implements ComponentPaletteListener, MouseListener,
      WindowCloserCallback {
      boolean clickedMouse = false;

      Panel myPanel = new Panel();

      public PaletteGui() {
      super();

      // Register against a WindowCloser to process my window closed event
      WindowCloser myCloser = new WindowCloser(this, true);

      setBounds(0, 0, 1, 1);
      setVisible(true);

      myPanel.setBounds(getInsets().left, getInsets().top, 150, 64);
      myPanel.setLayout(new GridBagLayout());
      myPanel.setBackground(Color.lightGray);
      setLayout(new GridBagLayout());
      add(myPanel, newConstraint(GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
      0, 0, 1, 1, 0, 0));
      }

      public void componentRemoved(ComponentPaletteEvent e) {
      }

      public void componentAdded(ComponentPaletteEvent e) {
      LightweightPanel newPanel = new LightweightPanel();
      newPanel.setLayout(new GridBagLayout());
      newPanel.add(new BitmapCanvas(IconManager.getIcon(e.getComponentName())),
      newConstraint(GridBagConstraints.WEST, GridBagConstraints.NONE,
      0, 0, 1, 1, 2, 2));

      Label newLabel = new Label(e.getComponentName());


      newPanel.add(newLabel, newConstraint(GridBagConstraints.WEST, GridBagConstraints.NONE,
      1, 0, 1, 1, 2, 2));

      myPanel.add(newPanel, newConstraint(GridBagConstraints.WEST, GridBagConstraints.NONE,
      0, GridBagConstraints.RELATIVE, 1, 1, 0, 0));

      newLabel.addMouseListener(this);

      // Re-size panel
      setResizable(true);
      Dimension newDimension = myPanel.getPreferredSize();
      setBounds(0, 0, newDimension.width + getInsets().left + getInsets().right,
      newDimension.height + getInsets().top + getInsets().bottom);
      setResizable(false);
      validate();
      }

      private GridBagConstraints newConstraint(int anchor, int fill, int grdx, int grdy, int grdw, int grdh,
      int pdx, int pdy) {
      GridBagConstraints temp = new GridBagConstraints();

      temp.anchor = anchor;
      temp.fill = fill;
      temp.gridx = grdx;
      temp.gridy = grdy;
      temp.gridwidth = grdw;
      temp.gridheight = grdh;
      temp.ipadx = pdx;
      temp.ipady = pdy;
      return temp;
      }

      public void mouseClicked(MouseEvent e) {
      // Debug.message(Debug.GUI, "mouseClicked");
      if (!clickedMouse)
      Debug.message(Debug.GUI, "Discarded false click");

      clickedMouse = false;
      }

      public void mouseEntered(MouseEvent e) {
      // Debug.message(Debug.GUI, "mouseEntered");
      }

      public void mouseExited(MouseEvent e) {
      // Debug.message(Debug.GUI, "mouseExited");
      }

      public void mousePressed(MouseEvent e) {

      // Bugfix for problem with JDK 1.1.3 related to 4039858
      clickedMouse = true;
      // Debug.message(Debug.GUI, "mousePressed");

      Object source = e.getSource();

      if (source instanceof java.awt.Label) {
      Debug.message(Debug.GUI, "Component selected " + ((Label) source).getText());
      }
      }

      public void mouseReleased(MouseEvent e) {
      // Debug.message(Debug.GUI, "mouseReleased");
      }

      public void windowClosing() {
      Debug.message(Debug.GUI, "Palette Closing");
      }
      }

      company - Tao Systems Ltd , email - ###@###.###
      ======================================================================


      phil.race@eng 1997-11-06

      yet another duplicate of 4038721 fixed in JDK 1.1.5

            jdunnsunw Jeffrey Dunn (Inactive)
            johsunw Joon Oh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: