JScrollPane- Only Vertical Scroll?

﹥>﹥吖頭↗ 提交于 2019-12-10 17:47:03

问题


I have the following line of code:

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

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:


+1 to trashgods comment.

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

To illustrate this:

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

UPDATE

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



来源:https://stackoverflow.com/questions/13466279/jscrollpane-only-vertical-scroll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!