简体   繁体   English

如何隐藏垂直滚动窗格但使用其功能?

[英]How to hide vertical scrollpane but use its function?

I have a simple Java swing application. 我有一个简单的Java swing应用程序。 In my JPanel, I have a simple JScrollPane but I don't want to show the vertical scrollbar. 在我的JPanel中,我有一个简单的JScrollPane,但我不想显示垂直滚动条。 So, I have build this code: 因此,我建立了以下代码:

jScrollPaneRicetta = new JScrollPane();
jScrollPaneRicetta.setViewportView(vp);
jScrollPaneRicetta.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
jScrollPaneRicetta.setPreferredSize(dTabellaRicetta);

Now with this code, I don't show the vertical scrollpane, but if the table have more row, I can't scroll the table to show the last row. 现在,使用此代码,我不会显示垂直滚动窗格,但是如果表中有更多行,则无法滚动表以显示最后一行。 Now, my question is, how can I hide the vertical scrollpane but use its function? 现在,我的问题是,如何隐藏垂直滚动窗格但使用其功能?

you can set the viewport 您可以设置视口

int x,y;//wherever you want to set
jScrollPaneRicetta.getViewportView().setViewPosition(new Point(x,y));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM