简体   繁体   English

如何在右端设置水平滚动窗格的起始位置?

[英]How set horizontal scroll pane starting location on the right end?

I have a JScrollPane built like this:我有一个像这样构建的JScrollPane

JScrollPane scrollBar1 = new JScrollPane (tableForDay1, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

so that I can scroll up/down left/right.这样我就可以向上/向下向左/向右滚动。
and I want the scroller to start on the right when launching the application.我希望滚动条在启动应用程序时从右侧开始。 It starts on the left by default.默认情况下,它从左侧开始。

how can I do that?我怎样才能做到这一点?

在此处输入图片说明

Given a JScrollPane you could get the horizontal scrollbar component (a JScrollBar) and then set its value to the maximum:给定 JScrollPane,您可以获得水平滚动条组件(JScrollBar),然后将其值设置为最大值:

//renamed scrollBar1 because is a misleading name
JScrollPane scrollPane1= new JScrollPane (tableForDay1,
        JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JScrollBar horScrBar= scrollPane1.getHorizontalScrollBar();
horScrBar.setValue(horScr.getMaxValue());

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

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