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

unix: jck1.3 test api/java_awt/interactive/DnDTests.html#DnDTests fails

XMLWordPrintable

    • x86
    • linux



      Name: icR10030 Date: 05/30/2000



      The test api/java_awt/interactive/DnDTests.html#DnDTests from jck1.3 testsuite fails.

      The problem is that after D&D "Button" the button is in the state as left mouse
      button is down.

      To reproduce bug compile and run following test's source DnDTests.java.
      Then drag and drop button "Button".
      Then move cursor over the button - it will change it's state to pressed state.
      Move cursor out of the button - it will change state to non-pressed state.

      The bug is reproduced in linux and solaris environment, win32 is OK.

      JDK version:
      % java -hotspot -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)

      //--------------------------- DnDTests.java ----------------------------------
      import java.lang.reflect.*;
      import java.awt.datatransfer.*;
      import java.awt.dnd.*;
      import java.io.*;
      import java.awt.*;
      import java.awt.event.*;


      public class DnDTests extends Frame implements ActionListener {
          public static void main(String [] argv) {
              new DnDTests().init();
          }

          void init() {
      Panel testPanel = new Panel(new BorderLayout());
      Panel nP = new Panel(new GridLayout(0,2));

      nP.add(new Label("DragSource", Label.CENTER));
      nP.add(new Label("DropTarget", Label.CENTER));
      testPanel.add("North", nP);
      testPanel.add("Center", new Panel1());
              add(testPanel);

              setSize(200,200);
              setVisible(true);
          }

          class Panel1 extends Panel {
              List dropList = new List();
      Button dragButton = new Button("Button");
              DragSource dragSource = new DragSource();

      DragGestureRecognizer [] recognizer = {
      (dragSource.createDefaultDragGestureRecognizer(
      dragButton, // Component
      DnDConstants.ACTION_COPY_OR_MOVE, // actions
      new dragGL(dragSource)) // DragGestureListener
      ),
      };

              DropTarget dropTarget = new DropTarget(
      dropList, // Component
      DnDConstants.ACTION_COPY_OR_MOVE, // actions
      new DropTargetListener() {
      public void dragEnter(DropTargetDragEvent e) {
      e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
      }
      public void drop(DropTargetDropEvent e) {
      try {
      if(e.isDataFlavorSupported(DataFlavor.stringFlavor)){
      Transferable tr = e.getTransferable();
      e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
      String s = (String)
      tr.getTransferData(DataFlavor.stringFlavor);
      dropList.add(s);
      e.dropComplete(true);
      } else {
      e.rejectDrop();
      }
      } catch (IOException io) {
      io.printStackTrace();
      e.rejectDrop();
      } catch (UnsupportedFlavorException ufe) {
      ufe.printStackTrace();
      e.rejectDrop();
      } catch (NullPointerException npe) {
      npe.printStackTrace();
      e.rejectDrop();
      }
      }
      public void dragExit(DropTargetEvent e) {}
      public void dragOver(DropTargetDragEvent e) {}
      public void dropActionChanged(DropTargetDragEvent e) {}
      });

      // implementation of the gesture listener
      class dragGL implements DragGestureListener {
           DragSource dragSource;
      dragGL(DragSource dragSource) {
      this.dragSource = dragSource;
      }
      public void dragGestureRecognized(DragGestureEvent e) {
      Component c = e.getComponent();
      String s = "";
      if (c instanceof Button) s = ((Button) c).getLabel();

      e.startDrag(DragSource.DefaultCopyDrop, // cursor
      new StringSelection(s), // transferable
      new dragSL() // DragSourceListener
      );
      }
      }

      // DragSourceListener
      class dragSL implements DragSourceListener {
      public void dragDropEnd(DragSourceDropEvent e) {}
      public void dragEnter(DragSourceDragEvent e) {}
      public void dragExit(DragSourceEvent e) {}
      public void dragOver(DragSourceDragEvent e) {}
      public void dropActionChanged(DragSourceDragEvent e) {}
      }

      public Panel1() {
      setLayout(new GridLayout(1, 2, 10, 10));
      setBackground(new Color (226,184,153)); // beige

      // the source panel
      GridBagLayout gbl = new GridBagLayout();
      Panel sP = new Panel(gbl);
      GridBagConstraints gbc = new GridBagConstraints();

      gbc.gridx = 0;
      gbc.gridy = 2;
      gbc.anchor = GridBagConstraints.WEST;
      gbl.setConstraints(dragButton, gbc);
      dragButton.setBackground(Color.pink);
      sP.add(dragButton);
      add(sP);

      Panel tP = new Panel (new BorderLayout());
      tP.add("Center", dropList);
      add(tP);
      }
          }
         
          public void actionPerformed(ActionEvent e) {
          }
      }
      //--------------------------- the end ----------------------------------------

      ======================================================================

            dmendenhsunw David Mendenhall (Inactive)
            ichesunw Iche Iche (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: