-
Bug
-
Resolution: Unresolved
-
P4
-
8, 17, 21, 24, 25, 26
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
The doc indicates return value is "always positive", but sometimes it return 0.
---------- BEGIN SOURCE ----------
import java.awt.Dimension;
import java.awt.Rectangle;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
public class JListTest {
public static void main(String[] argv) throws Exception {
SwingUtilities.invokeAndWait(() -> {
JFrame f = new JFrame();
String[] data = {"One", "Two", "Three", "Four", "Five", "Six ", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelv"};
JList<String> list = new JList<>(data);
list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
JScrollPane sp = new JScrollPane(list);
sp.setPreferredSize(new Dimension(200, 200));
f.add(sp);
f.pack();
f.setVisible(true);
Rectangle cell = list.getCellBounds(0, 0);
int unit = list.getScrollableUnitIncrement(
cell,
SwingConstants.VERTICAL,
-1);
System.out.println("Scrollable unit increment: " + unit);
if (unit <= 0) {
throw new RuntimeException("JList scrollable unit increment should be greater than 0.");
}
f.dispose();
});
}
}
---------- END SOURCE ----------
The doc indicates return value is "always positive", but sometimes it return 0.
---------- BEGIN SOURCE ----------
import java.awt.Dimension;
import java.awt.Rectangle;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
public class JListTest {
public static void main(String[] argv) throws Exception {
SwingUtilities.invokeAndWait(() -> {
JFrame f = new JFrame();
String[] data = {"One", "Two", "Three", "Four", "Five", "Six ", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelv"};
JList<String> list = new JList<>(data);
list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
JScrollPane sp = new JScrollPane(list);
sp.setPreferredSize(new Dimension(200, 200));
f.add(sp);
f.pack();
f.setVisible(true);
Rectangle cell = list.getCellBounds(0, 0);
int unit = list.getScrollableUnitIncrement(
cell,
SwingConstants.VERTICAL,
-1);
System.out.println("Scrollable unit increment: " + unit);
if (unit <= 0) {
throw new RuntimeException("JList scrollable unit increment should be greater than 0.");
}
f.dispose();
});
}
}
---------- END SOURCE ----------
- csr for
-
JDK-8365843 JList getScrollableUnitIncrement return 0
-
- Draft
-
- links to
-
Review(master) openjdk/jdk/26500