Victor Gontar
Victor Gontar

Reputation: 33

How do I anchor my Horizontal Scrollbar to the top of the JScrollPane

I would like to move the Horizontal scroll bar to the top of my JScrollPane. Does anyone knows how to do this ? I am on Java swing.

Upvotes: 3

Views: 349

Answers (2)

Victor Gontar
Victor Gontar

Reputation: 33

This worked for me.

jScrollPane.setColumnHeaderView(jScrollPane.getHorizontalScrollBar());

Upvotes: 0

camickr
camickr

Reputation: 324197

Start by reading the JScrollPane API.

At the right of the first page you will see a simple diagram showing the layout of the scroll pane. You will see:

  1. positions for the horizontal (and vertical) scrollbars
  2. a location titled the "column header"

So what you need to do is move the horizontal scrollbar to the column header. To this you need to:

  1. get a reference to the horizontal scrollbar. Read the API for the appropriate "getter" method
  2. set the scrollbar to the column header. Read the API for the appropriate "setter" method.

Upvotes: 3

Related Questions