JTextArea outputArea = new JTextArea( 17, 20 );
创建一个JTextArea 的实例,大小是17行,20列
JScrollPane scroller = new JScrollPane( outputArea );
创建一个JScrollPane得实例,并把哪个JTextArea 加到这个滚动面板内。

解决方案 »

  1.   

    qxjavajava(射手座 =---> 你今天JAVA了吗) 说的很对呀!
    补充的是下一句是为一个文本域加一个滚动条!
      

  2.   

    你去看JScrollPane的原代码就知道了嘛!
    帮你up!
      

  3.   

    各位还未明白我的意思
    JTextArea outputArea = new JTextArea( 17, 20 );
    JScrollPane scroller = new JScrollPane( outputArea );应该这样来解释:(这样详细些我才明白.老外们不都是这样详细吗?)JTextArea 声明一个对象 outputArea 并用new 创建,然后初始化(在它的参数中)为17行,20列的JTextArea的一个实例. 只是第二行中的参数:outputArea 我不明白放它在这里的意义,它对于JScrollPane 实例化的 scroller 有什么影响,这样的一种初始化的格式或着说方式是不是可以分开写,分开怎么写呢? 具体每一步的步骤.还有做这步的含义是什么?详细,详细,再详细.  因为我很菜,被笑话我.谢谢各位啦  :)
      

  4.   

    JScrollPane(Component view) 
    Creates a JScrollPane that displays the contents of the specified component, where both horizontal and vertical scrollbars appear whenever the component's contents are larger than the view.
      

  5.   

    JTextArea(int rows, int columns) 
    Constructs a new empty TextArea with the specified number of rows and columns.
      

  6.   

    qxjavajava(射手座 =---> 你今天JAVA了吗) 解释的非常明白
      

  7.   

    public JScrollPane(Component view)
    Creates a JScrollPane that displays the contents of the specified component, where both horizontal and vertical scrollbars appear whenever the component's contents are larger than the view. Parameters:
    view - the component to display in the scrollpane's viewport
      

  8.   

    JTextArea outputArea = new JTextArea( 17, 20 );
    生成一个JTextArea的实例,实例名叫outputArea,实例属性是17行高,20列宽。
    JScrollPane scroller = new JScrollPane(outputArea);
    生成一个JScrollPane的实例,实例名叫scroller,实例里面放的是outputArea。
    这只是一种构造方法,还可以用下面代码进行编写:      JTextArea outputArea = new JTextArea();
          outputArea.setRows(17);
          outputArea.setColumns(20);
          JScrollPane scroller = new JScrollPane();
          scroller.setViewportView(outputArea);可能象上边这样写更清楚一点。试着看看吧
    ================================================================
    AllForOne.freejacky