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

removing lightweight comp causes drag events to disappear

XMLWordPrintable

    • x86
    • windows_95, windows_nt

      Name: paC48320 Date: 10/07/97


      /*This is a resubmission of a bug report as requested
      by Peter J. Allenbach OPCOM Consuntant 9.19.97.
      Below I provide
      an example of code which reproduces the bug.

      if you run the program and then press and drag the
      mouse over the red lightweight component you will
      see that once the component is removed subsequent
      drag events are not recieved by either the Frame
      or the lightweight. If you change 'Component'
      to 'Canvas' and make the component heavyweight
      you will see the drag events are recieved by
      the Frame after the removal of the Canvas.*/
      //***********************************************
      import java.awt.*; import java.awt.event.*;
      class Test extends Frame{
      Test handle;
         Test(){enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);
      handle=this; setLayout(null); LW lw=new LW(); add(lw); lw.setBounds(0,0,50,50);
      setSize(100,100); setVisible(true);
         }
         public void processMouseMotionEvent(MouseEvent me){
        if(me.getID()==MouseEvent.MOUSE_DRAGGED)System.out.println("Test Drag event");
      super.processMouseMotionEvent(me);
        }
       class LW extends Component{//inner class
         LW(){enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);}
         public void processMouseEvent(MouseEvent me){
      if(me.getID()==MouseEvent.MOUSE_PRESSED){
      handle.remove(this); handle.repaint(); System.out.println("LW removed");}
      super.processMouseEvent(me);
         }
         public void processMouseMotionEvent(MouseEvent me){
        if(me.getID()==MouseEvent.MOUSE_DRAGGED)System.out.println("LW Drag event");
      super.processMouseMotionEvent(me);
        }
         public void update(Graphics G){paint(G);}
         public void paint(Graphics G){
      Dimension dim=getSize();
      G.setColor(Color.red); G.fillRect(0,0,dim.width,dim.height);
         }
       }//end of LW
         public static void main(String args[]){new Test();}
      }
      //***********************************************
      ======================================================================

            Unassigned Unassigned
            pallenba Peter Allenbach (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: