Charles Mosndup
Charles Mosndup

Reputation: 610

JScrollPane: How to move the scroll bar to the left and have the viewport align on the right

If I put the JScrollPane scroll bar on the left side, the left part of the viewport is placed under the scrollbar.

jScrollPane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

How to align the viewport to the right of the scrollbar?

Upvotes: 1

Views: 232

Answers (1)

Charles Mosndup
Charles Mosndup

Reputation: 610

Found the answer here : http://forums.codeguru.com/ Thanks to Rafke. It works fine.

jScrollPane.setLayout(new ScrollPaneLayout() {
    @Override
    public void layoutContainer(Container parent) {
        JScrollPane scrollPane = (JScrollPane) parent;
        scrollPane.setComponentOrientation(
            ComponentOrientation.RIGHT_TO_LEFT);
            super.layoutContainer(parent);
            scrollPane.setComponentOrientation(
                ComponentOrientation.LEFT_TO_RIGHT);
    }
});

Upvotes: 1

Related Questions