nspQuestionArea = new NScrollPane();
nspQuestionArea.setVerticalScrollBarPolicy
(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
nspQuestionArea.setVerticalScrollBarPolicy
(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
nspQuestionArea.setViewportView(getNpQuestionArea());
//where getNpQuestionArea() return a panel
nspQuestionArea.getVerticalScrollBar().setValue(0);
nspQuestionArea.getVerticalScrollBar().setValue(0);
nspQuestionArea.getVerticalScrollBar().setUnitIncrement(5);
nspQuestionArea.setOpaque(false);
如果我打開面板,垂直滾動條從面板中間開始,我需要始終從頂部開始滾動條。始終從頂部開始垂直滾動條
是否有任何方法可以做到這一點?
在此先感謝
是的有方法可以做到這一點,但視口視圖可能會自動改變它。例如,可編輯的JTextPane會自動嘗試顯示插入位置並可能自動觸發滾動。考慮發佈[SSCCE](http://sscce.org),以便我們可以仔細檢查您的問題 –