首页 > 解决方案 > ScrollPane 文本始终从底部开始

问题描述

基本上我的程序有一个JTabbedPane,每个选项卡都有JTextPane一个JScrollPane. 不知何故,但总是文本从底部开始。我该如何解决?

我试图把这个,但它没有工作。

JScrollBar vertical = scrollPane.getVerticalScrollBar();

JScrollPane scrollPane = new JScrollPane();
scrollPane.setEnabled(false);
scrollPane.setBounds(10, 36, 973, 492);
panel.add(scrollPane);
JScrollBar vertical = scrollPane.getVerticalScrollBar();
vertical.setValue(vertical.getMaximum()); 

JTextPane textPane = new JTextPane();
textPane.setEditable(false);
textPane.setFont(new Font("Calibri Light", Font.BOLD, 20));
textPane.setText("blahblahbalhtonsoftexthere");
scrollPane.setViewportView(textPane);

标签: javaswingjscrollpanejtextpane

解决方案


推荐阅读