I want customize the JScrollBar Design. I use Mac to develop the app with eclipse. I already tried to scrollPane.getVerticalScrollBar().setBackground(Color.BLACK);
but nothing happen.
My code:
scrollPane = new JScrollPane(scriptView);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
scrollPane.getVerticalScrollBar().setUnitIncrement(6);
window.getContentPane().add(scrollPane);
The Object scriptView
is from the class JEditorPane
.
How it should look:
Thanks for every help.
Sadly the proposed solutions will break JTable and won't display the table header, but I found this solution that seems to work.
I guess you are looking for a transparent scrollbar.
This is just presented as an idea(NOT tested code):
Here is an improved version I did for a private project. It also supports horizontal scrollbar.
Code:
Custom scrollbar preview
public class CustomScrollBarUI extends BasicScrollBarUI {
Then:
YOUR_COMPONENT.getVerticalScrollBar().setUI(new CustomScrollBarUI());