-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1.7
-
generic
-
generic
Name: krT82822 Date: 05/30/99
[note: this bug is still present in Swing 1.1.1 beta2, used in tandem with JDK 1.1.8. Bug was filed against earlier Swing version
and JDK 1.1.7 --kevin.ryan@eng, 5/30/99]
If you add a rowHeader to a JScrollPane it WILL keep it in sync
when scrolling in the component that JScrollPane controls
(usually given in the constructor). However, when scrolling
in the rowHeader (the viewPort) by clicking and dragging
(autoscrolling) the rowHeader scrolls independent of the component
under ScrollPanes control.
The synchronization is one-way, it should be both ways.
Try the following test class to reproduce the problem:
// ScrollTest.java
//
import java.awt.*;
import java.awt.event.*;
import com.sun.java.swing.*;
import com.sun.java.swing.table.*;
/**
* This class demonstrates a bug with the JScrollPane and its
* associated rowHeader. Auto scrolling works correctly when you
* click and drag in the second list. However, if you click and
* drag in the leftmost list (the rowHeader), the rowHeader list
* scrolls freely and does not synchronize with the data list.
* This seems to most definitely be a bug as there is only a
* one-way synchronization provided by the JScrollPane
**/
public class ScrollTest extends JFrame
{
public ScrollTest()
{
// housekeeping
super("Scroll Test");
setSize(300, 200);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
// create two lists, one for our header and one for our data
String[] data = {"one", "two", "free", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen"};
JList headerList = new JList(data);
JList dataList = new JList(data);
// create a header viewPort for attaching to scroll pane
JViewport headerViewPort = new JViewport();
headerViewPort.setView(headerList);
headerViewPort.setPreferredSize(headerList.getMaximumSize());
// Have the scroll pane control the data list and have the
// header list as its rowHeader
JScrollPane scrollPane = new JScrollPane(dataList);
scrollPane.setRowHeader(headerViewPort);
getContentPane().add(scrollPane, BorderLayout.CENTER);
}
public static void main(String args[]) {
ScrollTest st = new ScrollTest();
st.setVisible(true);
}
}
(Review ID: 49015)
======================================================================
- duplicates
-
JDK-4227520 auto-scrolling JScollPane
-
- Closed
-