See the GUI:
Notice a white line between the container and the scrollbar:
Is it possible to make this line disappear?
Code:
public class WhitePixels {
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
JFrame f = new JFrame("A");
JPanel container = new JPanel();
container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
for (int i = 0; i < 15; i++) {
container.add(new JButton("A"));
}
f.setLayout(new BorderLayout());
//some attempts
JScrollPane sp = new JScrollPane(container);
sp.getVerticalScrollBar().setOpaque(false);
sp.getVerticalScrollBar().setBorder(BorderFactory.createEmptyBorder());
sp.setOpaque(false);
f.add(sp);
f.pack();
f.setSize(200, 200);
f.setLocationByPlatform(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}
Windows 10, Java 1.8


I changed the above code to:
and you will see the white line is still there on the inside of the border.
This implies the line is part of the painting of the scrollbar.
I tried playing with the UIManager to change some of the color defaults:
but it had no effect.
I got the above values from UIManager Defaults in case you want to try your luck.
So I would suggest the only way to get rid of the white line is to override the LAF and do your own custom painting, which is not a task I would know how to do.