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
?
UIManager.put("ScrollBarUI", MyScrollbarUI.class.getName());
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.