我没用过JTextPane,为什么不用JTextArea
JTextArea txt=new JTextArea();
JScrollPane sb=new JScrollPane(txt,JScrollPane.HORI....,JScrollPane.V.....);
具体的参数我记不住,你自己去查文档

解决方案 »

  1.   

    import javax.swing.*;
    import java.awt.Dimension;public class Test {
      JFrame frame ;
      JPanel pane ;
      JScrollPane sPane ;
      JTextPane textPane ;  public Test() {
        jbInit();
      }
      public void jbInit(){
        frame = new JFrame("......") ;
        pane = new JPanel() ;
        textPane = new JTextPane() ;
        sPane = new JScrollPane(textPane) ;
        textPane.setPreferredSize(new Dimension(250, 150));
        frame.getContentPane().add(pane) ;
        pane.add(sPane, null) ;
        frame.setSize(300,200) ;
        frame.setVisible(true) ;
      }  public static void main(String[] args) {
        Test test = new Test();
      }
    }<------ 树欲静而风不止 ------>
      

  2.   

    是不是说要想实现JTextPane的滚动只有把它加入到JScrollPane中,JTextPane不是继承自JComponent吗?JComponent有setAutoScrolls(boolean)可以设置组件是否可以滚动,不是吗?
      

  3.   

    setAutoScrolls()
    是设置鼠标的,你用过吗?