本文介绍了JScrollPane-仅垂直滚动吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码行:

JSplitPane VPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,(new class1()),new JScrollPane(new class2()));

我想让class2仅具有垂直滚动吗?由于我的布局落在其他地方.我正在使用GridBagLayout,现在更改布局为时已晚.有解决此问题的方法吗?

I'd like class2 to ONLY have vertical scrolling please? Since my layout falls to bits otherwise.I am using GridBagLayout and it's too late to change the layout now. Is there a method to fix this?

推荐答案

+1进行垃圾评论.

为了说明这一点:

JScrollPane js=...; //Create a variable reference to the an instance of scrollpane

JSPlitPane jsp;

js.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);//set the horizontal scrollbar to never appear

jsp=new JSplitPane(..,js);//create the splitpane with the jscrollpane etc

更新

我建议您创建对变量/组件的引用,特别是因为您以后可能希望动态修改它们.

I would recommend creating references to your variables/components especially because you might want to modify them dynamically later.

这篇关于JScrollPane-仅垂直滚动吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 17:40