I created my own MyScrollbarUI class to have a custom scrollbar look in my application. Now I have to do
scrollPane.getHorizontalScrollBar().setUI(new MyScrollbarUI());
scrollPane.getVerticalScrollBar().setUI(new MyScrollbarUI());
on any ScrollPane I use.
Is it somehow possible to tell Swing that it should use MyScrollbarUI on any scrollbar. Maybe via the UIManager?
should do the trick.
You need to have a
public static ComponentUI createUI(JComponent c)method in your UI class, returning an instance of your UI.