我有下面的代码片段JScrollPane中设置滚动位置
query_area = new JTextArea("");
query_scroll_pane = new JScrollPane(query_area);
query_scroll_pane.setSize(1000,80);
query_scroll_pane.setLocation(10,10);
query_panel.add(query_scroll_pane);
这增加了我的textarea到滚动窗格。为textarea的如
sf.query_area.setText("Query "+(sf.query_counter)+sf.query_store[sf.query_counter]);
System.out.println("Position: "+sf.query_scroll_pane.getHorizontalScrollBar().getValue());
现在的方法我动态设置文本现在我的查询时,显示较长的文本,滚动条出现,但作为滚动0而不是一些增加值的System.out.println打印位置。
为什么这样?
水平或垂直滚动位置?位于JScrollBar上的滑块在哪里?此外,您的问题标题是关于*设置*滚动位置,当您确实似乎在询问*获取*滚动位置。这是什么? –
我想我是用隐形墨水在上面写下我的评论的? –
我的问题并不清楚,因为你的评论听起来很正确。它已经很清楚,并且从下面的一条评论中得到了答案。无论如何,谢谢 –