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

Ellipsis don't appear in JList when contained in JScrollPane

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.4.1
    • client-libs



      Name: jk109818 Date: 07/29/2002


      FULL PRODUCT VERSION :
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      Normally ellipsis appear in a list box item that's too long
      to be fully displayed. However, it's possible to get the
      list box into a state where ellipsis *don't* appear when
      the list box (JList) is contained in a JScrollPane
      that doesn't have a horizontal scrollbar.

      I've provided a simple application to demonstrate this
      problem.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      There are 2 list boxes displayed in this application. The
      list box on the right uses JScrollPane. The list box on the
      left doesn't. Click the button to add a long string to both
      list boxes.

        Bug #1: (Ellipsis are not displayed in JList contained in
      JScrollPane)
      Maximize, then restore app to its original size. Now
      ellipsis in the right list box are not displayed!
      Click the button again to clear & reload the same data.
      Ellipsis are now in the right list box as they should be.

        Bug #2: (Vertical scrollbar present when it shouldn't be)
      The right list box shouldn't have a scrollbar since the
      JScrollPane was created with VERTICAL_SCROLLBAR_AS_NEEDED.

      Note:
      In my application ellipsis are never displayed when I use
      JScrollPane with my list box. So the corrupted state
      I'm able to get JList/JScrollPane in for this bug report,
      is *always* the state in my application. So there's
      obviously more to bug #1.

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;
      import java.awt.event.*;
      import javax.swing.border.*;

      class JavaBug3 extends JFrame
      {
      DefaultListModel leftListModel, rightListModel;
      String longString = "We the people of the United States, in order to
      form a more perfect union,";

      JavaBug3()
      {
      super();

      setTitle("JScrollPane Bugs");

      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      JButton button = new JButton("<Click to load data into
      listboxes>");

      button.addActionListener(new ActionListener()
      { public void actionPerformed(ActionEvent e)
      {
      leftListModel.clear();
      leftListModel.addElement("Without JScrollPane");
      leftListModel.addElement(longString);

      rightListModel.clear();
      rightListModel.addElement("With JScrollPane");
      rightListModel.addElement(longString);
      }
      });

      leftListModel = new DefaultListModel();
      rightListModel = new DefaultListModel();

      JList leftList = new JList(leftListModel), rightList = new JList
      (rightListModel);

      leftList.setPreferredSize(new Dimension(200, 200));
      rightList.setPreferredSize(new Dimension(200, 200));

      JScrollPane scrollPane = new JScrollPane(rightList,
      JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
      JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

      getContentPane().add(leftList, BorderLayout.WEST);

      getContentPane().add(button, BorderLayout.CENTER);

      getContentPane().add(scrollPane, BorderLayout.EAST);

      pack();
      }

      public static void main(String[] args)
      {
      new JavaBug3().show();
      }
      }
      ---------- END SOURCE ----------
      (Review ID: 146182)
      ======================================================================

            apikalev Andrey Pikalev
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: