classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] Patch for Approval: JList getFirstVisibleIndex and getLastV


From: Anthony Balkissoon
Subject: [cp-patches] Patch for Approval: JList getFirstVisibleIndex and getLastVisibleIndex
Date: Tue, 02 Aug 2005 16:25:16 -0400

This patch fixes an off-by-one-pixel problem in getFirstVisibleIndex and
getLastVisibleIndex.

I discovered this problem running the simple test case at the bottom of
this email and using the PAGE DOWN key.  Without this patch, 1 pixel of
a list item is showing at the bottom and thus page down does nothing
more than the down arrow key.

Patch attached.

2005-08-02  Anthony Balkissoon  <address@hidden>

* javax/swing/JList.java:
(getFirstVisibleIndex): Translate visible rectangle by one less pixel.
(getLastVisibleIndex): Likewise.


===TEST CASE ===
import java.awt.*;
import javax.swing.*;
import java.io.*;

class Test
{
  public static void main(String[] args) throws IOException
  {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    String[] items = 
                     {
                       "Item1", "Item2", "Item3", "Item4", "Item5",
"Item6",
                       "Item7", "Item8", "Item9", "Item10", "Item11",
"Item12", "Item13",
                       "Item14", "Item15", "Item16", "Item17", "Item18"
                     };
    JList list = new JList(items);
    list.setPreferredSize(new Dimension(150, 150));

    JScrollPane scroller = new JScrollPane();
    scroller.getViewport().setView(list);

    f.getContentPane().add(scroller);
    f.setSize(100, 200);

    f.show();
  }
}

-Tony

Attachment: JListGetFirstLastVisibleFix.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]