user2821023
user2821023

Reputation: 511

JScrollPane set enabled to false

I've JScrollPane with table inside it.

scroll = new JScrollPane(table);
scroll.setBorder(BorderFactory.createLineBorder(Color.black));
add(scroll);

I want to disable it, but

scroll.setEnabled(false);

does nothing.

Is there a way to disable scroll pane?

Upvotes: 0

Views: 1464

Answers (1)

Sanjeev
Sanjeev

Reputation: 9946

JScrollPane.setEnabled(false) does not work as suggested, it is a bug, in order to get the same behavior you need to do the following:

scroll.getHorizontalScrollBar().setEnabled(false);
scroll.getVerticalScrollBar().setEnabled(false);
scroll.getViewport().getView().setEnabled(false);

Hope this helps.

Upvotes: 2

Related Questions