Tapas Bose
Tapas Bose

Reputation: 29816

No Scrollbar - JScrollPane with JPanel

I have a JSplitPane with

JSplitPane jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, movieSearchResultTableScrollPane, movieSearchInfoScrollPane);

I have set:

jSplitPane.setOneTouchExpandable(true);

The movieSearchResultTableScrollPane has a JTable and if drag the splitpane to the left, a horizontal scrollbar is going to visible after some length.

The movieSearchInfoScrollPane has a JPanel movieSearchInfoPanel attached as:

movieSearchInfoScrollPane.setViewportView(movieSearchInfoPanel);

movieSearchInfoPanel has some label components. And I didn't specify any kind of size to the movieSearchInfoPanel. But If I drag the splitpane to the right I am not getting horizontal scrollbar movieSearchInfoScrollPane.

How can I resolve this problem?

Upvotes: 1

Views: 1089

Answers (1)

StanislavL
StanislavL

Reputation: 57421

You can call setPreferredSize() for the movieSearchInfoPanel.

But it's better to use LayoutManager set for the panel. Then all the children componnets' pref sizes are used to calculate pref size of container and scroll appear automatically.

Upvotes: 3

Related Questions