If you are using the basic version of JScrollBar, then this is probably rendering using BasicScrollBarUI. I would suggest you extend BasicScrollBarUI to create a user interface (e.g. MyBasicScrollBarUI). Buttons are protected variables in the superclass. Therefore, you need to override the installComponents () methods in the subclass and not add buttons. See the code snippet below and hide the lines as suggested there.
protected void installComponents(){ switch (scrollbar.getOrientation()) { case JScrollBar.VERTICAL: incrButton = createIncreaseButton(SOUTH); decrButton = createDecreaseButton(NORTH); break; case JScrollBar.HORIZONTAL: if (scrollbar.getComponentOrientation().isLeftToRight()) { incrButton = createIncreaseButton(EAST); decrButton = createDecreaseButton(WEST); } else { incrButton = createIncreaseButton(WEST); decrButton = createDecreaseButton(EAST); } break; } scrollbar.add(incrButton);
Then in your code, after initializing the JScrollBar, you can call setUI () and pass an instance of the MyBasicScrollBarUI class.
Note. I have not tried this myself, but from the code it looks as if it could work.
Thimmayya
source share