new 一个JTextArea,可就是没有滚动条,AWT包的TextArea就不会没有滚动条了,Swing包是怎么搞的,再用JTextArea的setAutoscrolls(true),问题仍旧,add(JScrollPane),add(JScrollBar),都不行。

解决方案 »

  1.   

    JTextArea textArea = new JTextArea();
    JScrollPane scrollPane = new JScrollPane(textArea);
    panel.add(scrollPane, ...
      

  2.   

    JScrollPane scrollPane = new JScrollPane();
    scrollPane .setViewPortView(textArea);
      

  3.   

    回复人: zhouqi724(猛男) 
    JScrollPane scrollPane = new JScrollPane();
    scrollPane .setViewPortView(textArea);
    行不通,类型不同。
    setViewPortView(),request"JViewport",but textArea is JTextArea.------------------------------------------------------------------
    回复人: gtlang78() 
    JTextArea textArea = new JTextArea();
    JScrollPane scrollPane = new JScrollPane(textArea);
    panel.add(scrollPane, ...Thank you ,run!!!!!!!!!!!