JScrollPane-仅垂直滚动吗? [英] JScrollPane- Only Vertical Scroll?

查看:239
本文介绍了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进行垃圾评论.

它似乎不起作用-我只是遇到错误= [

It doesn't seem to work- I'm just getting errors =[

为了说明这一点:

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-仅垂直滚动吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆