无滚动条 - JScrollPane 与 JPanel

发布于 2025-01-08 07:41:56 字数 705 浏览 4 评论 0 原文

我有一个 JSplitPane,

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

我已经设置了:

jSplitPane.setOneTouchExpandable(true);

movieSearchResultTableScrollPane 有一个 JTable,如果将分割窗格拖动到左侧,水平滚动条将在一定长度后可见。

movieSearchInfoScrollPane 有一个附加的 JPanel movieSearchInfoPanel

movieSearchInfoScrollPane.setViewportView(movieSearchInfoPanel);

movieSearchInfoPanel 有一些标签组件。我没有为 MovieSearchInfoPanel 指定任何类型的大小。但是,如果我将分割窗格拖到右侧,我就不会得到水平滚动条movieSearchInfoScrollPane

我该如何解决这个问题?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萤火眠眠 2025-01-15 07:41:56

您可以为 movieSearchInfoPanel 调用 setPreferredSize()。

但最好使用为面板设置的LayoutManager。然后,所有子组件的首选项大小都用于计算容器的首选项大小,并且滚动会自动出现。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文