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

shift-click no longer extends selection in Swing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • client-libs
    • beta2
    • x86
    • windows_nt



      Name: bsC130419 Date: 07/10/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)

      /*
        Program to illustrate the shift-click bug.

      Under JDK 1.3 and earlier, if I first click into a JTextComponent with
      text, then I shift-click elsewhere, the text between the click and the
      previous caret will become selected. This is the desired behavior, and
      is standard for every GUI that I've ever used. However, under JDK 1.4beta,
      this no longer happens. Shift-click behaves the same way as an ordinary
      click.

        To reproduce, run this program. Click into the JTextField, the JTextArea,
      or the JEditorPane. Hold down the shift key and click elsewhere in the
      same component. Under JDK 1.3 or earlier, the text between the two clicks
      will get selected. Under JDK 1.4beta, no text will get selected.

      This bug shows up under the metal, windows, and motif looks and feels. I
      didn't test under any others. I presume it's cross platform, but I have
      only tested it under Windows.

      PLEASE fix this before the release of JDK 1.4. It's so annoying when a new
      release breaks an existing feature that I use a lot.
      */

      import javax.swing.*;
      import java.awt.event.*;
      import java.awt.*;
      import javax.swing.plaf.multi.*;
      import javax.swing.plaf.basic.*;
      import javax.swing.plaf.metal.*;

      public class ShiftClickBug extends JFrame
      {
        public static void main(String[] args)
        {
          // Uncomment a pair of lines to test under a different look and feel.
      // try {
      UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); }
      //
      catch (Exception err) { }
      // try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }
      //
      catch (Exception err) { }
          new ShiftClickBug();
        }
        
        ShiftClickBug()
        {
          super("Control-Arrow Bug");
          addWindowListener(new WindowAdapter()
            { public void windowClosing(WindowEvent evt) { System.exit(0); } } );
          setBounds(20, 20, 400, 300);
          String jdkvers = System.getProperty("java.version");
          JTextField fld = new JTextField("This is a test. Java version = " +
      jdkvers);
          JTextArea area = new JTextArea("This is also a test. \nJava version = " +
      jdkvers);
          JScrollPane areaScr = new JScrollPane(area);
          JEditorPane editor = new JEditorPane();
          editor.setText("And this is a test. \nJava version = " + jdkvers);
          JScrollPane edScr = new JScrollPane(editor);
          Container cp = getContentPane();
          cp.setLayout(new BorderLayout());
          JPanel dualPanel = new JPanel(new GridLayout(0,1));
          cp.add(fld, "North");
          dualPanel.add(areaScr);
          dualPanel.add(edScr);
          cp.add(dualPanel, "Center");
          show();
        }
      }
      (Review ID: 127794)
      ======================================================================

            ssisunw Ssi Ssi (Inactive)
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: