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

Mousedragged events are limited in the internal frame before it's been activated

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.1
    • 1.4.0
    • client-libs
    • hopper
    • x86
    • windows_nt
    • Verified



      Name: yyT116575 Date: 09/24/2001


      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
      Java HotSpot(TM) Client VM (build 1.4.0-beta2-b77, mixed mode)
      Operation System: Windows NT (4.0)


      Mousedragged events are limited if the internal frame has not been
      activated before.

      If one starts dragging within an internal frame, disactived frame, this frame
      will be obviously activated but drag information are limited to the size of
      the component on which one started the drag operation. This behavior is
      differnt from 1.3.1.

      If the mouse is pressed then released to get the frame activated separately
      from the drag operation, and then one starts the drag operation, one will
      be able to get information about the internal frame and even about the
      whole desktop without limitation as in the 1.3.1.

      --------------------


      /**
       * MouseDragInternalFrameMerlin.java
       */
      import java.lang.*;
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.event.*;
      import javax.swing.border.*;

      /**
       * Class: MouseDragInternalFrameMerlin
       */
      public class MouseDragInternalFrameMerlin extends JFrame {
        /**
         * Constructor: MouseDragInternalFrameMerlin
         * @return instance of MouseDragInternalFrameMerlin
         */
        public MouseDragInternalFrameMerlin() {
          /* JFrame - Bean Properties */
          setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
          setTitle("MouseDragInternalFrameMerlin");
          /* JFrame - sets Bounds */
          setBounds(40,63,400,400);
          /* JFrame - Adds Child */
          JDesktopPane desktopPane = new JDesktopPane();
          desktopPane.setBackground(new Color(204,204,204));
          getContentPane().add(desktopPane,java.awt.BorderLayout.CENTER);
                                
          /* JInternalFrame1 - Bean Properties */
          JInternalFrame internalFrame = new JInternalFrame();
          internalFrame.setTitle("F1");
          /* JInternalFrame1 - sets Bounds */
          internalFrame.setBounds(10,10,250,180);
          /* JInternalFrame1 - Adds Child */
          final JLabel drag1 = new JLabel("Drag me");
          drag1.setBounds(20,20,100,100);
          drag1.setBorder(new EtchedBorder(EtchedBorder.LOWERED,null,null));
          drag1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent e) {
              drag1.requestFocus();
              drag1.setText("" + e.getX() + " " + e.getY());
            }

            public void mouseMoved(java.awt.event.MouseEvent e) {
            }
          });
          JPanel panel1 = new JPanel();
          panel1.setLayout(null);
          panel1.add(drag1);
          internalFrame.getContentPane().add(panel1,java.awt.BorderLayout.CENTER);
          /* JDesktopPane - Adds Child */
          desktopPane.add(internalFrame);
          internalFrame.show();
              
          /* JInternalFrame 2 - Bean Properties */
          internalFrame = new JInternalFrame();
          internalFrame.setTitle("F2");
          /* JInternalFrame 2 - sets Bounds */
          internalFrame.setBounds(100,100,250,180);
          /* JInternalFrame 2 - Adds Child */
          final JLabel drag2 = new JLabel("Drag me");
          drag2.setBounds(20,20,100,100);
          drag2.setBorder(new EtchedBorder(EtchedBorder.LOWERED,null,null));
          drag2.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent e) {
              drag2.requestFocus();
              drag2.setText("" + e.getX() + " " + e.getY());
            }

            public void mouseMoved(java.awt.event.MouseEvent e) {
            }
          });
          JPanel panel2 = new JPanel();
          panel2.setLayout(null);
          panel2.add(drag2);
          internalFrame.getContentPane().add(panel2,java.awt.BorderLayout.CENTER);
          /* JDesktopPane - Adds Child */
          desktopPane.add(internalFrame);
          internalFrame.show();
                         
        } /* End of Constructor: MouseDragInternalFrameMerlin */
                 
        /**
         * Method: main <br>
         * Note: Called only if we're an application. <br>
         * @param java.lang.String[] args the command line arguments
         * @return void
         */
        public static void main(java.lang.String[] args) {
          try {
            /* Creates new MainObject */
            MouseDragInternalFrameMerlin self = new MouseDragInternalFrameMerlin();
            self.show();
          } /* End try */
          catch (java.lang.Throwable exc) {
            exc.printStackTrace(System.err);
          } /* End catch */
        } /* End of Method: main */

      } /* End of Class: MouseDragInternalFrameMerlin */
      (Review ID: 132501)
      ======================================================================

            joutwatesunw Joshua Outwater (Inactive)
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: