Jonas Byström
Jonas Byström

Reputation: 26179

JScrollPane with scroll bar to left

I need to place a scroll bar to the left of the contents in my JScrollPane. Can it be done without a separate JScrollBar component? Perhaps simply by setting some alignment?

Upvotes: 12

Views: 6673

Answers (3)

Trynkiewicz Mariusz
Trynkiewicz Mariusz

Reputation: 2782

Accepted answer gade my GridBagLayout panel inability to stretch horizontally (and it seems there is more to it with components' preferred size bug #5727254)

I found solution for this:

leftPanelScroll.setRowHeaderView(leftPanelScroll.getVerticalScrollBar());

I hope it will help yet another poor soul.

Upvotes: 1

Mannuel
Mannuel

Reputation: 47

I tried changing the alignment of the track div from 'right' to 'left' in the css class .jspVerticalBar. seems to work.

.jspVerticalBar
{
    position: absolute;
    top: 0;
    left: 0;
    width: 16px;
    height: 100%;
    background: red;
}

Upvotes: -4

Jonas Byström
Jonas Byström

Reputation: 26179

Using trial and error I found that

JScrollPane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

worked like a charm.

Upvotes: 16

Related Questions