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

JList setSelectedValue(value, true) does not scroll

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.1
    • client-libs



      Name: bsC130419 Date: 05/10/2001


      java version "1.3.1-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-beta-b15)
      Java HotSpot(TM) Client VM (build 1.3.1beta-b15, interpreted mode)


      JList does not scroll to selected item for setSelectedValue(value, true), but
      the item is selected, as can be seen if the user scrolls manually. The attached
      code works correctly run under 1.2.2, but does not scroll under 1.3.0 or 1.3.1.

      import java.awt.*;
      import javax.swing.*;

      public class JListBug {

         public static void main(String args[]) {

            JFrame jFrame = new JFrame();
            JPanel jPanel = new JPanel();
            JScrollPane jScrollPane;

            String[] names = { "aaaaa", "bbbbb", "ccccc", "ddddd", "eeeee", "fffff",
                               "ggggg", "hhhhh", "iiiii", "jjjjj", "kkkkk", "lllll",
                               "mmmmm", "nnnnn", "ooooo", "ppppp", "qqqqq", "rrrrr",
                               "sssss", "ttttt", "uuuuu", "vvvvv", "wwwww", "xxxxx",
                               "yyyyy", "zzzzz" };

            JList jList = new JList(names);
            jScrollPane = new JScrollPane(jList);

            jPanel.setLayout(new GridBagLayout());
            jPanel.add(jScrollPane,
                       new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                                              GridBagConstraints.CENTER,
                                              GridBagConstraints.NONE,
                                              new Insets(0, 0, 0, 0),
                                              0, 0));

            jList.setSelectedValue("xxxxx", true); // <---<< Neither of these
            jList.ensureIndexIsVisible(23); // <---<< work under 1.3.0

            jFrame.getContentPane().add(jPanel);
            jFrame.pack();
            jFrame.setVisible(true);
         }
      }
      (Review ID: 124124)
      ======================================================================

      This is a duplicate submission (accidental) of bug 4457325. Sorry.
      bill.strathearn@Eng 2001-05-10

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: