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

JList with a border interferes with JScrollPane's ArrowButton Listeners

XMLWordPrintable

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



      Name: ks88420 Date: 08/21/2000


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

      When you add a border to a JList that is being added to a JScrollPane, it
      causes the ArrowButtons of the scrollbar not to work until you move the
      scrollbar by another means. The problem arises with any type of Border that I
      add to the JList. The following Test Application demonstrates this:

      public class TestJList extends javax.swing.JFrame{
      javax.swing.JList jList;
      javax.swing.JScrollPane jScrollPane;

      public TestJList(){
      super();
      this.addWindowListener(new java.awt.event.WindowAdapter() {
      public void windowClosed
      (java.awt.event.WindowEvent e) {
      System.exit(0);
      };
      });
      this.setDefaultCloseOperation
      (javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
      this.setSize(460, 300);
      this.getContentPane().setLayout(new java.awt.FlowLayout());
      jScrollPane = new javax.swing.JScrollPane();
      jList = new javax.swing.JList();
      jList.setModel(new javax.swing.DefaultListModel());
      //following line sets the border on the JList
      //Comment this out if you want the JScrollPane's scrollbar to
      work properly
      jList.setBorder(javax.swing.BorderFactory.createLineBorder
      (java.awt.Color.lightGray));
      for(int i = 0; i < 10 ; i++){
      ((javax.swing.DefaultListModel)jList.getModel
      ()).addElement("Item Added to the JList");
      }
      jScrollPane.setViewportView(jList);
      this.getContentPane().add(jScrollPane);

      this.show();
      }

      public static void main (String args []){
      new TestJList();
      }

      }
      (Review ID: 106295)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            skonchad Sandeep Konchady
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: