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

Swing DnD should not use selection to show drop location

XMLWordPrintable

    • b42
    • generic, x86, sparc
    • generic, linux, solaris_9, windows_nt, windows_2000

        In Swing, the selection is used to show the point where a drop operation would occur. With text components, this is the caret. In JList, JTable, JTree, the selection is used.

        This causes many complications. With text, playing with the caret causes the selection to be temporary lost as described in the report below. With the other components, using the selection makes it difficult to specify a drop above or below the current selection.

        A new mechanism should be designed such that a drop location can be displayed without using the selection.

        -----------------------------------
        Original bug report:

        Name: bsC130419 Date: 06/11/2001


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

        Dragging selected text from a text component deselects the original text. The
        original text is deselected as soon as the drag starts. I expect the original
        text to remain selected until the text is dropped on a target.
        Set setDragEnabled on a JTextField, JTextArea, JTextPane, JFormattedTextField
        or JEditorPane to true to select default drag operation. After selecting some
        text and starting to drag, the text becomes unselected.
        The example code shows a frame with each of the text components in it. The
        components have had their default drag operation enabled so that drag and drop
        of text can by played with. Select some text in any component and drag it. As
        soon as the selected text is dragged the original text becomes unselected.

        /*
         * Test.java
         *
         * Created on 6 June 2001, 16:08
         */


        /**
         *
         * @author daz
         * @version 1.0
         */
        public class Test extends javax.swing.JFrame {

            /** Creates new form Test */
            public Test() {
                initComponents ();
                jFormattedTextField1 = new javax.swing.JFormattedTextField();
                jFormattedTextField1.setText("jFormattedTextField1");
                getContentPane().add(jFormattedTextField1);
                jTextArea1.setDragEnabled(true);
                jTextField1.setDragEnabled(true);
                jTextPane1.setDragEnabled(true);
                jEditorPane1.setDragEnabled(true);
                jFormattedTextField1.setDragEnabled(true);
                pack ();
            }

            /** This method is called from within the constructor to
             * initialize the form.
             * WARNING: Do NOT modify this code. The content of this method is
             * always regenerated by the FormEditor.
             */
            private void initComponents() {//GEN-BEGIN:initComponents
              jTextArea1 = new javax.swing.JTextArea();
              jTextField1 = new javax.swing.JTextField();
              jTextPane1 = new javax.swing.JTextPane();
              jEditorPane1 = new javax.swing.JEditorPane();
              
              getContentPane().setLayout(new java.awt.GridLayout(0, 1));
              
              addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                  exitForm(evt);
                }
              });
              
              jTextArea1.setText("jTextArea1");
              getContentPane().add(jTextArea1);
              
              jTextField1.setText("jTextField1");
              getContentPane().add(jTextField1);
              
              jTextPane1.setText("jTextPanel1");
              getContentPane().add(jTextPane1);
              
              jEditorPane1.setText("jEditorPane1");
              getContentPane().add(jEditorPane1);
              
            }//GEN-END:initComponents

            /** Exit the Application */
            private void exitForm(java.awt.event.WindowEvent evt) {//GEN-
        FIRST:event_exitForm
                System.exit (0);
            }//GEN-LAST:event_exitForm

            /**
            * @param args the command line arguments
            */
            public static void main (String args[]) {
                new Test ().show ();
            }


            // Variables declaration - do not modify//GEN-BEGIN:variables
            private javax.swing.JTextArea jTextArea1;
            private javax.swing.JTextField jTextField1;
            private javax.swing.JTextPane jTextPane1;
            private javax.swing.JEditorPane jEditorPane1;
            // End of variables declaration//GEN-END:variables
            private javax.swing.JFormattedTextField jFormattedTextField1;
        }
        (Review ID: 126245)
        ======================================================================

              shickeysunw Shannon Hickey (Inactive)
              bstrathesunw Bill Strathearn (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: